vozlt / nginx-module-stream-sts

Nginx stream server traffic status core module
BSD 2-Clause "Simplified" License
68 stars 23 forks source link

display_handler::shm_init() failed #2

Open Joungkyun opened 7 years ago

Joungkyun commented 7 years ago

OS: CentOS 6.9

Nginx info:

or

load_module "/usr/lib64/nginx/ngx_stream_module.so";
load_module "/usr/lib64/nginx/ngx_stream_server_traffic_status_module.so";
load_module "/usr/lib64/nginx/ngx_http_stream_server_traffic_status_module.so";

or

load_module "/usr/lib64/nginx/ngx_http_stream_server_traffic_status_module.so";

nginx-module-stream-sts : 0.1.0 release version

nginx config:

load_module "/usr/lib64/nginx/ngx_http_geoip_module.so";
#load_module "/usr/lib64/nginx/ngx_http_image_filter_module.so";
#load_module "/usr/lib64/nginx/ngx_http_perl_module.so";
load_module "/usr/lib64/nginx/ngx_http_stream_server_traffic_status_module.so";
#load_module "/usr/lib64/nginx/ngx_http_vhost_traffic_status_module.so";
#load_module "/usr/lib64/nginx/ngx_http_xslt_filter_module.so";
#load_module "/usr/lib64/nginx/ngx_mail_module.so";
#load_module "/usr/lib64/nginx/ngx_stream_module.so";
#load_module "/usr/lib64/nginx/ngx_stream_geoip_module.so";
#load_module "/usr/lib64/nginx/ngx_stream_server_traffic_status_module.so";

http {
     ...
    stream_server_traffic_status on;
    stream_server_traffic_status_zone;
    ...

    server {

        listen     80 default_server;
        server_name  _;

        location / {
            try_files     $uri $uri/ =404;
            root          /usr/share/nginx/html;
            index         index.html index.php;
        }

        location ~ ^/(robots\.txt|favicon\.ico)($|/) {
            log_not_found off;
            access_log off;
        }

        localtion /status {
            stream_server_traffic_status_display;
            stream_server_traffic_status_display_format html;
        }

        # Error documents
        location ~ /nginx-error/error.html {
            internal;
            alias /usr/share/nginx/html/error.html;

            ssi on;
            set $hstatus $args;
            access_log off;
        }

        # Fancyindex
        location /fancyindex/ {
            alias /usr/share/nginx/fancyindex/;
        }

        #
        # logging off
        #
        location = /robots.txt {
            log_not_found off;
            access_log    off;
        }

        location = /favicon.ico {
            log_not_found off;
            access_log    off;
        }

        location ~ \.(dat|cfg|orig|org|bak|rpmsave|save|,v|tpl|la?ng|modules?|engines?|install|inc|ini|ph)$ {
            deny all;
        }

        location ~ \.(htaccess|htgroup|htpasswd) {
            deny all;
        }

        location ~ /(temp|sessions?|class(es)?)/ {
            deny all;
        }
    }
}

And access http://domain.com/status, occurs follow error:

[error] 10391#0: *1 display_handler::shm_init() failed, client: 192.168.0.1, server: _, request: "GET /status HTTP/1.1", host: "domain.com"
vozlt commented 7 years ago

Hi, Thanks for reporting. Please make sure you use the server_traffic_status_zone directive. The directive server_traffic_status_zone in stream block is essential because the shared memory zone using in nginx-module-sts, nginx-module-stream-sts is allocated by that directive. The process finding shared memory zone is as follows:

  1. nginx-module-stream-sts -> server_traffic_status_zone -> Allocate shared memory zone
  2. nginx-module-sts -> stream_server_traffic_status_display -> Find shared memory zone