location {} access_log off -> no such file or directory

J Carter jordanc.carter at outlook.com
Wed Feb 28 17:35:01 UTC 2024


Hello,

On Mon, 26 Feb 2024 09:55:10 +0100
"Roberto D. Maggi" <robertodmaggi at gmail.com> wrote:

> Hi you all,
> 
> I'm trying to improve the reverse proxy's virtual hosts' configuration 
> files of my company,
> 
> but I'm facing an issue that I can't understand:
> 
> 
> In the "location / " block I inserted these lines
> 
> location ~* 
> ^.+\.(eot|otf|woff|woff2|ttf|rss|atom|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ 
> {
> access_log off; log_not_found off; expires max;
> }
> 
> and everythings fine,
> 
> ==> /var/log/nginx/MYSITEcom.access.log <==
> 
> 172.18.0.1 - - [26/Feb/2024:08:36:44 +0000] "GET 
> /wp-content/themes/MYSITE/images/back-numbers.png HTTP/1.1" 200 264666 
> "https://www.MYSITE.com/wp-content/themes/MYSITE/css/style.css?ver=5.6.1" 
> "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) 
> Chrome/122.0.0.0 Safari/537.36"
> 
> it doesn's log the gets to these extentions and so on but when I put the 
> following line,
> 
> location ~* \.(?:css|js)$ {
> expires 1y;
> access_log off;
> add_header Cache-Control "public";
> }
> 
> the site changes aspect and logs are filles with "no such file or directory"
> 
> ==> /var/log/nginx/MYSITE.com.error.log <==
> 2024/02/26 08:34:46 [error] 107#107: *336 open() 
> "/etc/nginx/html/wp-content/themes/MYSITE/webfonts/Roboto-Regular.ttf" 
> failed (2: No such file or directory), client: 172.18.0.1, server: 
> www.MYSITE.com, request: "GET 
> /wp-content/themes/MYSITE/webfonts/Roboto-Regular.ttf HTTP/1.1", host: 
> "www.MYSITE.com", referrer: 
> "https://www.MYSITE.com/wp-content/themes/MYSITE/css/style.css?ver=5.6.1"
> 
> It looks like it changes, some way, the root directory, but being 
> reverse proxies I didn't set it up.
> 
> 
> here below you can fine the virtual host conf file.
> 
> thanks in advance for every suggestion
> 
> Rob
> 

Nested locations don't inherit the proxy_pass directive, you still
need to repeat that in there, like this:

location ~* \.(?:css|js)$ {
    expires 1y;
    access_log off;
    add_header Cache-Control "public";
    proxy_pass https://MYSITE.portals:97/;
}



More information about the nginx mailing list