Opened 4 years ago

Closed 4 years ago

#1889 closed defect (invalid)

access_log off; returns 404 with nginx proxy

Reported by: rameshsahoo11@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.16.x
Keywords: Cc: rameshsahoo11@…
uname -a: Linux nginx-test 3.10.0-1062.4.1.el7.x86_64 #1 SMP Wed Sep 25 09:42:57 EDT 2019 x86_64 Linux
nginx -V: nginx version: nginx/1.16.1
built with OpenSSL 1.1.1d 10 Sep 2019 (running with OpenSSL 1.1.1c 28 May 2019)
TLS SNI support enabled
configure arguments: --prefix=/var/lib/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --pid-path=/run/nginx/nginx.pid --lock-path=/run/nginx/nginx.lock --http-client-body-temp-path=/var/tmp/nginx/client_body --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-perl_modules_path=/usr/lib/perl5/vendor_perl --user=nginx --group=nginx --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-stream_ssl_preread_module --add-dynamic-module=/home/buildozer/aports/main/nginx/src/njs-0.3.1/nginx --add-dynamic-module=/home/buildozer/aports/main/nginx/src/ngx_devel_kit-0.3.0 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/ngx_cache_purge-2.5 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/echo-nginx-module-0.61 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/ngx-fancyindex-0.4.3 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/headers-more-nginx-module-0.33 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/lua-nginx-module-0.10.15 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/lua-upstream-nginx-module-0.07 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/nchan-1.2.5 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/nginx-http-shibboleth-2.0.1 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/redis2-nginx-module-0.15 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/set-misc-nginx-module-0.32 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/nginx-upload-progress-module-0.9.2 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/nginx-upstream-fair-0.1.3 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/nginx-rtmp-module-1.2.1 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/nginx-vod-module-1.24 --add-dynamic-module=/home/buildozer/aports/main/nginx/src/ngx_http_geoip2_module-3.2

Description

Summary:

With nginx reverse proxy mode, I am trying to turn off access_log for a specific location. Doing so Nginx returns 404 for that location. Refer to the following example.

Front-end Nginx configuration:

server {

listen 80 default_server;
listen [::]:80 default_server;
access_log /var/log/nginx/site1_access main;
error_log /var/log/nginx/site1_error debug;


location ~* /icons/* {

access_log off;

}

location / {

proxy_pass http://192.168.50.2;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;


}

}

Requirement:

=> My requirement is to turn off nginx logs on the backend server in order to save IO and configure the front-end to provide proxy pass and all website logs.

Refer to the following access and error logs.

============
Nginx logs
============

Main Page:http://172.17.0.2
==> /var/log/nginx/site1_access <==
172.17.0.1 - - [12/Nov/2019:09:52:26 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36" "-"

==> /var/log/nginx/site1_error <==
2019/11/12 09:54:10 [error] 188#188: *3 open() "/var/lib/nginx/html/icons/nginx-logo.png" failed (2: No such file or directory), client: 172.17.0.1, server: , request: "GET /icons/nginx-logo.png HTTP/1.1", host: "172.17.0.2"

The above logs indicate that nginx is trying serve the page from the front-end server instead of forwarding the request to backend.

Change History (1)

comment:1 by Ruslan Ermilov, 4 years ago

Resolution: invalid
Status: newclosed

The first location (with access_log tuned off) doesn't have proxy_pass, so it's handled by the static module looking up files according to the "root" directive.

Note: See TracTickets for help on using tickets.