Welcome! Log In Create A New Profile

Advanced

403 error logging

B.R.
June 26, 2014 02:24PM
Hello,

I recently stumbled into a situation where I could not seem to find a way
of disabling unwanted errors being logged.

Configuration:
location / {
try_files $uri $uri/ @https;
}

location @https {
return 301 https://$host$request_uri;
}

That works well for locations like '/foo' where it falls back to https
server.

However, when accessing root location '/', the '$uri/' part of the
try_files directive produces a 403 'directory index [...] is forbidden'.

I thought that adding 'error_page 403 @https;' to the prefix location would
override it, but no.

I also tried to use 'error_page 403 = @https;' to pass error processing to
the named location, hoping for the 301 redirection would cancel it.
Of course, that did not happen. ^^

Here are the solutions I envision, though none of them satisfy me:
1°) Using 'autoindex on;' in the prefix location: that is not the wanted
behavior
2°) Using 'try_files $uri @https;' in the prefix location would avoid
directory existence try... Although display of location /test if test is an
existing directory won't happen and fallback to he HTTPS server will occur.
That is not the wanted behavior
3°) Using 'error_page 403 = @https;' in the prefix location, then use
'error_log /dev/null;' in the named one, but that looks ugly, more like a
'hack'.
Moreover, it does not seem to work.

What to do then?

Since it seems I cannot prevent 403 to spawn out of the prefix location, is
there a way to send it to the named one and then trap it/ignore it there?

Thanks,
---
*B. R.*
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

403 error logging

B.R. June 26, 2014 02:24PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 176
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