Opened 7 years ago

Closed 7 years ago

#1425 closed defect (invalid)

Log path is inherited from custom error page location

Reported by: dkanavis@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.13.x
Keywords: Cc:
uname -a: Linux web1 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64 GNU/Linux
Linux web1 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64 GNU/Linux
Linux web1 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64 GNU/Linux
Linux web1 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64 GNU/Linux
Linux web1 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64 GNU/Linux
Linux web1 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2 (2017-04-30) x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.12.0
built by gcc 4.9.2 (Debian 4.9.2-10)
built with OpenSSL 1.0.2l 25 May 2017
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -DNGX_HAVE_INET6=0' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -L /usr/lib/x86_64-linux-gnu' --prefix=/opt/nginx/nginx-1.12.0 --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_flv_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_secure_link_module --with-http_sub_module --add-module=./debian/modules/ngx_pagespeed-1.12.34.2-stable --with-http_image_filter_module

Description

Hello.
It may be not truly a bug but it seems like an annoying configuration problem that has no point but causes troubles.

If you make a virtual host with separate access/error logs for different locations and one default access/error log, and then add custom error pages with their own locations, like:

access_log /var/log/nginx/my_site/access.log;
error_page 404 /404.html;
location = /404.html {
   root /www/my_site/error_pages;
}
location /static {
    access_log /var/log/nginx/my_site/static_access.log;
}

logger will write to default access log while you get an error in some specific location with it's custom log (in example, if we get 404 at /static/mistak.html, corresponding row will be added to access.log instead of static_access.log which looks logically correct).

Change History (1)

comment:1 by Maxim Dounin, 7 years ago

Resolution: invalid
Status: newclosed

Access logs are written in the context of the location which was used to process the request at the request completion. In the particular configuration request processing ends up in the location = /404.html due to the error_page configured, and hence the default access log is used.

If you want custom access log to be used for 404 errors in the particular location, consider either not configuring error_page at all, or using a custom error_page with the same access log configured.

Note: See TracTickets for help on using tickets.