Help with location context?
    de_nginx_noob 
    nginx-forum at nginx.us
       
    Fri Oct 16 14:29:26 UTC 2015
    
    
  
So this is my nginx.conf file :
http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request"
'
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    # Load modular configuration files from the /etc/nginx/conf.d
directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root          /usr/share/nginx/html;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
        location /test {
                log_format testLog 'testing test location block
[$time_local]';
                access_log /var/log/nginx/access.log testLog;
        }
        error_page 404 /404.html;
            location = /40x.html {
        }
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }
}
As you can see, most of it is default. I just changed the location context
to try and do a custom log whenever someone requests something that begins
with /test. Nginx is running on a vm called centos-7-nginx. 
When I try to use curl centos-7-nginx/test or when I type in
centos-7-nginx/test in the browser, it doesn't hit that location block and
instead logs these using the http context log command :
192.168.1.48 - - [16/Oct/2015:10:27:02 -0400] "GET /test HTTP/1.1" 404 3650
"-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:41.0) Gecko/20100101
Firefox/41.0" "2.242.71.204"     --- from browser
and 
192.168.1.48 - - [16/Oct/2015:10:27:59 -0400] "GET /test HTTP/1.1" 404 3650
"-" "curl/7.43.0" "-"      ---from curl
I've tried = /test, /test/, test, even regex, but nothing seems to get it to
map to /test. What am I missing here?
Posted at Nginx Forum: https://forum.nginx.org/read.php?2,262279,262279#msg-262279
    
    
More information about the nginx
mailing list