Welcome! Log In Create A New Profile

Advanced

Help with location context?

October 16, 2015 10:29AM
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?
Subject Author Posted

Help with location context?

de_nginx_noob October 16, 2015 10:29AM

Re: Help with location context?

Francis Daly October 17, 2015 04:02AM

Re: Help with location context?

de_nginx_noob October 18, 2015 03:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 232
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready