[GH-ISSUE #59] [feature request]Recommended to support the ability to get the line number where the nginx directive is located #29

Closed
opened 2026-02-28 01:20:35 +03:00 by kerem · 1 comment
Owner

Originally created by @sharelinux on GitHub (Dec 12, 2024).
Original GitHub issue: https://github.com/tufanbarisyildirim/gonginx/issues/59

Description.

It is recommended that the project support getting the location of the nginx directives in the original configuration file.

Scenarios of use.

Currently there is this need to configure constraints for a certain instruction block. Check whether this instruction configuration to meet the rules, check the verification piece by parsing the configuration instructions, enumeration or recursive implementation of the check rule comparison, but if the check does not meet the requirements, now need to return to the original file is located in the line, the front-end needs to highlight this line, and then for the error message or modification suggestions.

Currently found github.com/tufanbarisyildirim/gonginx.parser syntax parser on the line number is there, just missing the token into the parsing object (config.Block) on the missing, increase the set line number and get the line number method can be.

Solution.

Just add the GetLine(), SetLine(int) interface constraints to the IDirective interface and an implementation of that interface.

// github.com/tufanbarisyildirim/gonginx.parser
// lexer is the main tokenizer
type lexer struct {
    reader *bufio.Reader
    file string
    line int
    column int
    inLuaBlock bool
    Latest token.Token
}

// IDirective represents any directive
type IDirective interface {
    GetName() string //the directive name.
    GetParameters() []string
    GetBlock() IBlock
    GetComment() []string
    SetComment(comment []string)
    SetParent(IBlock)
    GetParent() IBlock
    GetLine() int // Get the line number of the command in the configuration file.
    SetLine(int) // set the line number of the command in the configuration file
    InlineCommenter
}

Interface constraints added
image

Entities that need to implement the interface
image

Test screenshots

Local analog data files

user                 nobody;
pid                  /run/nginx.pid;
worker_processes     auto;  # ok
# 配置Nginx worker进程最大打开文件数
worker_rlimit_nofile 8192;

# Load modules
include              /etc/nginx/modules-enabled/*.conf;

events {
    multi_accept       on;
    # 单个进程允许的客户端最大连接数
    worker_connections 4096;  # ok
    # 使用epoll模型
    use epoll;
}

http {
    charset                utf-8;
    sendfile                on;
    keepalive_timeout      65;
    tcp_nopush             on;
    tcp_nodelay            on;
    types_hash_max_size    2048;
    types_hash_bucket_size 64;

    # # 指定 DNS 解析器地址,这里使用了 Google 的公共 DNS 服务器
    resolver 8.8.8.8 [::1]:5353 valid=30s;

    #gzip模块设置
    gzip on; #开启gzip压缩输出
    gzip_min_length 1k;    #最小压缩文件大小
    gzip_buffers 4 16k;    #压缩缓冲区
    gzip_http_version 1.0;    #压缩版本(默认1.1,前端如果是squid2.5请使用1.0)
    gzip_comp_level 2;    #压缩等级
    gzip_types text/plain application/x-javascript text/css application/xml;    #压缩类型,默认就已经包含textml,所以下面就不用再写了,写上去也不会有问题,但是会有一个warn。
    gzip_vary on;

    #设定通过nginx上传文件的大小
    client_max_body_size 8m;
    #客户端请求头部的缓冲区大小。这个可以根据你的系统分页大小来设置,一般一个请求的头部大小不会超过1k,不过由于一般系统分页都要大于1k,所以这里设置为分页大小。分页大小可以用命令getconf PAGESIZE取得。
    client_header_buffer_size 32k;
    #缓冲区代理缓冲用户端请求的最大字节数
    client_body_buffer_size 128k;

    # MIME
    include                mime.types;
    default_type           application/octet-stream; # ok

    # Log Format
    log_format             cloudflare '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $http_cf_ray $http_cf_connecting_ip $http_x_forwarded_for $http_x_forwarded_proto $http_true_client_ip $http_cf_ipcountry $http_cf_visitor $http_cdn_loop';

    # Logging
    access_log             off;  # ok
    error_log              /var/log/nginx/error.log warn;

    # SSL
    ssl_session_timeout    1d;
    ssl_session_cache      shared:SSL:10m;
    ssl_session_tickets    off;

    # Diffie-Hellman parameter for DHE ciphersuites
    ssl_dhparam            /etc/nginx/dhparam.pem;

    # Mozilla Intermediate configuration
    ssl_protocols          TLSv1.2 TLSv1.3;
    ssl_ciphers            ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;

    # OCSP Stapling
    ssl_stapling           on;
    ssl_stapling_verify    on;
    resolver               1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s;
    resolver_timeout       2s;

    upstream dynamic {
        zone upstream_dynamic 64k;
        ip_hash;
        keepalive 32;
    
        server backend1.example.com      weight=5;
        server backend2.example.com:8080 fail_timeout=5s slow_start=30s;
        server 192.0.2.1                 max_fails=3;
        server backend3.example.com      resolve;
        server backend4.example.com      service=http resolve;
    
        server backup1.example.com:8080  backup;
        server backup2.example.com:8080  backup;
    }

    upstream hi {
        zone upstream_dynamic 32k;
        server 192.0.2.11                 max_fails=3;
        server 192.0.2.12                 max_fails=3;
        server 192.0.2.13                 max_fails=3;
    }

    server {
        location / {
            proxy_pass http://dynamic;
            health_check;
        }

        location /hi {
            proxy_pass http://hi;
            health_check;
        }
    }

    server {
        listen       80  default_server;
        listen      8080;
        server_name  _;
        return       444;
    }

    server {
        listen 80;
        listen      8081;
        server_name domain1.com www.domain1.com;
        location / { proxy_pass http://127.0.0.1:8080; }
    }

    # Load configs
    include                /etc/nginx/conf.d/*.conf;
    include                /etc/nginx/sites-enabled/*;

    # 隐藏版本号
    server_tokens off;
}

Test Results

===========GlobalBlocks==============
keyword: user, path: global.user, line: 1 params: [nobody]
keyword: pid, path: global.pid, line: 2 params: [/run/nginx.pid]
keyword: worker_processes, path: global.worker_processes, line: 3 params: [auto]
keyword: worker_rlimit_nofile, path: global.worker_rlimit_nofile, line: 5 params: [8192]
keyword: include, path: global.include, line: 8 params: [/etc/nginx/modules-enabled/*.conf]
===========EventsBlocks==============
keyword: multi_accept, path: events.multi_accept, line: 11 params: [on]
keyword: worker_connections, path: events.worker_connections, line: 13 params: [4096]
keyword: use, path: events.use, line: 15 params: [epoll]
===========HttpBlock.HttpGlobalBlocks==============
keyword: charset, path: http.charset, line: 19 params: [utf-8]
keyword: sendfile, path: http.sendfile, line: 20 params: [on]
keyword: keepalive_timeout, path: http.keepalive_timeout, line: 21 params: [65]
keyword: tcp_nopush, path: http.tcp_nopush, line: 22 params: [on]
keyword: tcp_nodelay, path: http.tcp_nodelay, line: 23 params: [on]
keyword: server_tokens, path: http.server_tokens, line: 24 params: [off]
keyword: types_hash_max_size, path: http.types_hash_max_size, line: 25 params: [2048]
keyword: types_hash_bucket_size, path: http.types_hash_bucket_size, line: 26 params: [64]
keyword: resolver, path: http.resolver, line: 29 params: [8.8.8.8 [::1]:5353 valid=30s]
keyword: gzip, path: http.gzip, line: 32 params: [on]
keyword: gzip_min_length, path: http.gzip_min_length, line: 33 params: [1k]
keyword: gzip_buffers, path: http.gzip_buffers, line: 34 params: [4 16k]
keyword: gzip_http_version, path: http.gzip_http_version, line: 35 params: [1.0]
keyword: gzip_comp_level, path: http.gzip_comp_level, line: 36 params: [2]
keyword: gzip_types, path: http.gzip_types, line: 37 params: [text/plain application/x-javascript text/css application/xml]
keyword: gzip_vary, path: http.gzip_vary, line: 38 params: [on]
keyword: client_max_body_size, path: http.client_max_body_size, line: 41 params: [8m]
keyword: client_header_buffer_size, path: http.client_header_buffer_size, line: 43 params: [32k]
keyword: client_body_buffer_size, path: http.client_body_buffer_size, line: 45 params: [128k]
keyword: include, path: http.include, line: 48 params: [mime.types]
keyword: default_type, path: http.default_type, line: 49 params: [application/octet-stream]
keyword: log_format, path: http.log_format, line: 52 params: [cloudflare '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $http_cf_ray $http_cf_connecting_ip $http_x_forwarded_for $http_x_forwarded_proto $http_true_client_ip $http_cf_ipcountry $http_cf_visitor $http_cdn_loop']
keyword: access_log, path: http.access_log, line: 55 params: [off]
keyword: error_log, path: http.error_log, line: 56 params: [/var/log/nginx/error.log warn]
keyword: ssl_session_timeout, path: http.ssl_session_timeout, line: 59 params: [1d]
keyword: ssl_session_cache, path: http.ssl_session_cache, line: 60 params: [shared:SSL:10m]
keyword: ssl_session_tickets, path: http.ssl_session_tickets, line: 61 params: [off]
keyword: ssl_dhparam, path: http.ssl_dhparam, line: 64 params: [/etc/nginx/dhparam.pem]
keyword: ssl_protocols, path: http.ssl_protocols, line: 67 params: [TLSv1.2 TLSv1.3]
keyword: ssl_ciphers, path: http.ssl_ciphers, line: 68 params: [ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384]
keyword: ssl_stapling, path: http.ssl_stapling, line: 71 params: [on]
keyword: ssl_stapling_verify, path: http.ssl_stapling_verify, line: 72 params: [on]
keyword: resolver, path: http.resolver, line: 73 params: [1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s]
keyword: resolver_timeout, path: http.resolver_timeout, line: 74 params: [2s]
keyword: include, path: http.include, line: 125 params: [/etc/nginx/conf.d/*.conf]
keyword: include, path: http.include, line: 126 params: [/etc/nginx/sites-enabled/*]
keyword: server_tokens, path: http.server_tokens, line: 129 params: [off]
===========HttpBlock.ServerGlobalBlocks==============
keyword: listen, name: http.server[1].listen, path: http.server.listen, line: 111 params: [80 default_server]
keyword: listen, name: http.server[1].listen, path: http.server.listen, line: 112 params: [8080]
keyword: server_name, name: http.server[1].server_name, path: http.server.server_name, line: 113 params: [_]
keyword: return, name: http.server[1].return, path: http.server.return, line: 114 params: [444]
keyword: listen, name: http.server[2].listen, path: http.server.listen, line: 118 params: [80]
keyword: listen, name: http.server[2].listen, path: http.server.listen, line: 119 params: [8081]
keyword: server_name, name: http.server[2].server_name, path: http.server.server_name, line: 120 params: [domain1.com www.domain1.com]
===========HttpBlock.UpstreamBlocks==============
keyword: upstream, name: http.upstream[0], path: http.upstream.upstream, line: 89 params: [dynamic]
keyword: zone, name: http.upstream[0].zone[0], path: http.upstream.zone, line: 77 params: [upstream_dynamic 64k]
keyword: ip_hash, name: http.upstream[0].ip_hash[0], path: http.upstream.ip_hash, line: 78 params: []
keyword: keepalive, name: http.upstream[0].keepalive[0], path: http.upstream.keepalive, line: 79 params: [32]
keyword: server, name: http.upstream[0].server[0], path: http.upstream.server, line: 81 params: [backend1.example.com weight=5]
keyword: server, name: http.upstream[0].server[1], path: http.upstream.server, line: 82 params: [backend2.example.com:8080 fail_timeout=5s slow_start=30s]
keyword: server, name: http.upstream[0].server[2], path: http.upstream.server, line: 83 params: [192.0.2.1 max_fails=3]
keyword: server, name: http.upstream[0].server[3], path: http.upstream.server, line: 84 params: [backend3.example.com resolve]
keyword: server, name: http.upstream[0].server[4], path: http.upstream.server, line: 85 params: [backend4.example.com service=http resolve]
keyword: server, name: http.upstream[0].server[5], path: http.upstream.server, line: 87 params: [backup1.example.com:8080 backup]
keyword: server, name: http.upstream[0].server[6], path: http.upstream.server, line: 88 params: [backup2.example.com:8080 backup]
keyword: upstream, name: http.upstream[1], path: http.upstream.upstream, line: 96 params: [hi]
keyword: zone, name: http.upstream[1].zone[0], path: http.upstream.zone, line: 92 params: [upstream_dynamic 32k]
keyword: server, name: http.upstream[1].server[0], path: http.upstream.server, line: 93 params: [192.0.2.11 max_fails=3]
keyword: server, name: http.upstream[1].server[1], path: http.upstream.server, line: 94 params: [192.0.2.12 max_fails=3]
keyword: server, name: http.upstream[1].server[2], path: http.upstream.server, line: 95 params: [192.0.2.13 max_fails=3]

Hopefully this suggestion will be taken up.

I will also raise a PR for support of this feature and hopefully adopt the merge.

Originally created by @sharelinux on GitHub (Dec 12, 2024). Original GitHub issue: https://github.com/tufanbarisyildirim/gonginx/issues/59 ### Description. It is recommended that the project support getting the location of the nginx directives in the original configuration file. ### Scenarios of use. Currently there is this need to configure constraints for a certain instruction block. Check whether this instruction configuration to meet the rules, check the verification piece by parsing the configuration instructions, enumeration or recursive implementation of the check rule comparison, but if the check does not meet the requirements, now need to return to the original file is located in the line, the front-end needs to highlight this line, and then for the error message or modification suggestions. Currently found github.com/tufanbarisyildirim/gonginx.parser syntax parser on the line number is there, just missing the token into the parsing object (config.Block) on the missing, increase the set line number and get the line number method can be. ### Solution. Just add the GetLine(), SetLine(int) interface constraints to the IDirective interface and an implementation of that interface. ```go // github.com/tufanbarisyildirim/gonginx.parser // lexer is the main tokenizer type lexer struct { reader *bufio.Reader file string line int column int inLuaBlock bool Latest token.Token } // IDirective represents any directive type IDirective interface { GetName() string //the directive name. GetParameters() []string GetBlock() IBlock GetComment() []string SetComment(comment []string) SetParent(IBlock) GetParent() IBlock GetLine() int // Get the line number of the command in the configuration file. SetLine(int) // set the line number of the command in the configuration file InlineCommenter } ``` > Interface constraints added ![image](https://github.com/user-attachments/assets/58b6232d-b16f-43c2-9dac-67c44e6d042e) > Entities that need to implement the interface ![image](https://github.com/user-attachments/assets/a204f62a-03d2-4029-9adb-6b9a23d02e7a) ### Test screenshots Local analog data files ```text user nobody; pid /run/nginx.pid; worker_processes auto; # ok # 配置Nginx worker进程最大打开文件数 worker_rlimit_nofile 8192; # Load modules include /etc/nginx/modules-enabled/*.conf; events { multi_accept on; # 单个进程允许的客户端最大连接数 worker_connections 4096; # ok # 使用epoll模型 use epoll; } http { charset utf-8; sendfile on; keepalive_timeout 65; tcp_nopush on; tcp_nodelay on; types_hash_max_size 2048; types_hash_bucket_size 64; # # 指定 DNS 解析器地址,这里使用了 Google 的公共 DNS 服务器 resolver 8.8.8.8 [::1]:5353 valid=30s; #gzip模块设置 gzip on; #开启gzip压缩输出 gzip_min_length 1k; #最小压缩文件大小 gzip_buffers 4 16k; #压缩缓冲区 gzip_http_version 1.0; #压缩版本(默认1.1,前端如果是squid2.5请使用1.0) gzip_comp_level 2; #压缩等级 gzip_types text/plain application/x-javascript text/css application/xml; #压缩类型,默认就已经包含textml,所以下面就不用再写了,写上去也不会有问题,但是会有一个warn。 gzip_vary on; #设定通过nginx上传文件的大小 client_max_body_size 8m; #客户端请求头部的缓冲区大小。这个可以根据你的系统分页大小来设置,一般一个请求的头部大小不会超过1k,不过由于一般系统分页都要大于1k,所以这里设置为分页大小。分页大小可以用命令getconf PAGESIZE取得。 client_header_buffer_size 32k; #缓冲区代理缓冲用户端请求的最大字节数 client_body_buffer_size 128k; # MIME include mime.types; default_type application/octet-stream; # ok # Log Format log_format cloudflare '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $http_cf_ray $http_cf_connecting_ip $http_x_forwarded_for $http_x_forwarded_proto $http_true_client_ip $http_cf_ipcountry $http_cf_visitor $http_cdn_loop'; # Logging access_log off; # ok error_log /var/log/nginx/error.log warn; # SSL ssl_session_timeout 1d; ssl_session_cache shared:SSL:10m; ssl_session_tickets off; # Diffie-Hellman parameter for DHE ciphersuites ssl_dhparam /etc/nginx/dhparam.pem; # Mozilla Intermediate configuration ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; # OCSP Stapling ssl_stapling on; ssl_stapling_verify on; resolver 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s; resolver_timeout 2s; upstream dynamic { zone upstream_dynamic 64k; ip_hash; keepalive 32; server backend1.example.com weight=5; server backend2.example.com:8080 fail_timeout=5s slow_start=30s; server 192.0.2.1 max_fails=3; server backend3.example.com resolve; server backend4.example.com service=http resolve; server backup1.example.com:8080 backup; server backup2.example.com:8080 backup; } upstream hi { zone upstream_dynamic 32k; server 192.0.2.11 max_fails=3; server 192.0.2.12 max_fails=3; server 192.0.2.13 max_fails=3; } server { location / { proxy_pass http://dynamic; health_check; } location /hi { proxy_pass http://hi; health_check; } } server { listen 80 default_server; listen 8080; server_name _; return 444; } server { listen 80; listen 8081; server_name domain1.com www.domain1.com; location / { proxy_pass http://127.0.0.1:8080; } } # Load configs include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; # 隐藏版本号 server_tokens off; } ``` #### Test Results ```text ===========GlobalBlocks============== keyword: user, path: global.user, line: 1 params: [nobody] keyword: pid, path: global.pid, line: 2 params: [/run/nginx.pid] keyword: worker_processes, path: global.worker_processes, line: 3 params: [auto] keyword: worker_rlimit_nofile, path: global.worker_rlimit_nofile, line: 5 params: [8192] keyword: include, path: global.include, line: 8 params: [/etc/nginx/modules-enabled/*.conf] ===========EventsBlocks============== keyword: multi_accept, path: events.multi_accept, line: 11 params: [on] keyword: worker_connections, path: events.worker_connections, line: 13 params: [4096] keyword: use, path: events.use, line: 15 params: [epoll] ===========HttpBlock.HttpGlobalBlocks============== keyword: charset, path: http.charset, line: 19 params: [utf-8] keyword: sendfile, path: http.sendfile, line: 20 params: [on] keyword: keepalive_timeout, path: http.keepalive_timeout, line: 21 params: [65] keyword: tcp_nopush, path: http.tcp_nopush, line: 22 params: [on] keyword: tcp_nodelay, path: http.tcp_nodelay, line: 23 params: [on] keyword: server_tokens, path: http.server_tokens, line: 24 params: [off] keyword: types_hash_max_size, path: http.types_hash_max_size, line: 25 params: [2048] keyword: types_hash_bucket_size, path: http.types_hash_bucket_size, line: 26 params: [64] keyword: resolver, path: http.resolver, line: 29 params: [8.8.8.8 [::1]:5353 valid=30s] keyword: gzip, path: http.gzip, line: 32 params: [on] keyword: gzip_min_length, path: http.gzip_min_length, line: 33 params: [1k] keyword: gzip_buffers, path: http.gzip_buffers, line: 34 params: [4 16k] keyword: gzip_http_version, path: http.gzip_http_version, line: 35 params: [1.0] keyword: gzip_comp_level, path: http.gzip_comp_level, line: 36 params: [2] keyword: gzip_types, path: http.gzip_types, line: 37 params: [text/plain application/x-javascript text/css application/xml] keyword: gzip_vary, path: http.gzip_vary, line: 38 params: [on] keyword: client_max_body_size, path: http.client_max_body_size, line: 41 params: [8m] keyword: client_header_buffer_size, path: http.client_header_buffer_size, line: 43 params: [32k] keyword: client_body_buffer_size, path: http.client_body_buffer_size, line: 45 params: [128k] keyword: include, path: http.include, line: 48 params: [mime.types] keyword: default_type, path: http.default_type, line: 49 params: [application/octet-stream] keyword: log_format, path: http.log_format, line: 52 params: [cloudflare '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $http_cf_ray $http_cf_connecting_ip $http_x_forwarded_for $http_x_forwarded_proto $http_true_client_ip $http_cf_ipcountry $http_cf_visitor $http_cdn_loop'] keyword: access_log, path: http.access_log, line: 55 params: [off] keyword: error_log, path: http.error_log, line: 56 params: [/var/log/nginx/error.log warn] keyword: ssl_session_timeout, path: http.ssl_session_timeout, line: 59 params: [1d] keyword: ssl_session_cache, path: http.ssl_session_cache, line: 60 params: [shared:SSL:10m] keyword: ssl_session_tickets, path: http.ssl_session_tickets, line: 61 params: [off] keyword: ssl_dhparam, path: http.ssl_dhparam, line: 64 params: [/etc/nginx/dhparam.pem] keyword: ssl_protocols, path: http.ssl_protocols, line: 67 params: [TLSv1.2 TLSv1.3] keyword: ssl_ciphers, path: http.ssl_ciphers, line: 68 params: [ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384] keyword: ssl_stapling, path: http.ssl_stapling, line: 71 params: [on] keyword: ssl_stapling_verify, path: http.ssl_stapling_verify, line: 72 params: [on] keyword: resolver, path: http.resolver, line: 73 params: [1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s] keyword: resolver_timeout, path: http.resolver_timeout, line: 74 params: [2s] keyword: include, path: http.include, line: 125 params: [/etc/nginx/conf.d/*.conf] keyword: include, path: http.include, line: 126 params: [/etc/nginx/sites-enabled/*] keyword: server_tokens, path: http.server_tokens, line: 129 params: [off] ===========HttpBlock.ServerGlobalBlocks============== keyword: listen, name: http.server[1].listen, path: http.server.listen, line: 111 params: [80 default_server] keyword: listen, name: http.server[1].listen, path: http.server.listen, line: 112 params: [8080] keyword: server_name, name: http.server[1].server_name, path: http.server.server_name, line: 113 params: [_] keyword: return, name: http.server[1].return, path: http.server.return, line: 114 params: [444] keyword: listen, name: http.server[2].listen, path: http.server.listen, line: 118 params: [80] keyword: listen, name: http.server[2].listen, path: http.server.listen, line: 119 params: [8081] keyword: server_name, name: http.server[2].server_name, path: http.server.server_name, line: 120 params: [domain1.com www.domain1.com] ===========HttpBlock.UpstreamBlocks============== keyword: upstream, name: http.upstream[0], path: http.upstream.upstream, line: 89 params: [dynamic] keyword: zone, name: http.upstream[0].zone[0], path: http.upstream.zone, line: 77 params: [upstream_dynamic 64k] keyword: ip_hash, name: http.upstream[0].ip_hash[0], path: http.upstream.ip_hash, line: 78 params: [] keyword: keepalive, name: http.upstream[0].keepalive[0], path: http.upstream.keepalive, line: 79 params: [32] keyword: server, name: http.upstream[0].server[0], path: http.upstream.server, line: 81 params: [backend1.example.com weight=5] keyword: server, name: http.upstream[0].server[1], path: http.upstream.server, line: 82 params: [backend2.example.com:8080 fail_timeout=5s slow_start=30s] keyword: server, name: http.upstream[0].server[2], path: http.upstream.server, line: 83 params: [192.0.2.1 max_fails=3] keyword: server, name: http.upstream[0].server[3], path: http.upstream.server, line: 84 params: [backend3.example.com resolve] keyword: server, name: http.upstream[0].server[4], path: http.upstream.server, line: 85 params: [backend4.example.com service=http resolve] keyword: server, name: http.upstream[0].server[5], path: http.upstream.server, line: 87 params: [backup1.example.com:8080 backup] keyword: server, name: http.upstream[0].server[6], path: http.upstream.server, line: 88 params: [backup2.example.com:8080 backup] keyword: upstream, name: http.upstream[1], path: http.upstream.upstream, line: 96 params: [hi] keyword: zone, name: http.upstream[1].zone[0], path: http.upstream.zone, line: 92 params: [upstream_dynamic 32k] keyword: server, name: http.upstream[1].server[0], path: http.upstream.server, line: 93 params: [192.0.2.11 max_fails=3] keyword: server, name: http.upstream[1].server[1], path: http.upstream.server, line: 94 params: [192.0.2.12 max_fails=3] keyword: server, name: http.upstream[1].server[2], path: http.upstream.server, line: 95 params: [192.0.2.13 max_fails=3] ``` Hopefully this suggestion will be taken up. I will also raise a PR for support of this feature and hopefully adopt the merge.
kerem closed this issue 2026-02-28 01:20:35 +03:00
Author
Owner

@amassx commented on GitHub (Dec 13, 2024):

I had a similar need to get the line number of the directive.

<!-- gh-comment-id:2540727765 --> @amassx commented on GitHub (Dec 13, 2024): I had a similar need to get the line number of the directive.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gonginx#29
No description provided.