<div dir="ltr"><div><div><div>Added auth_basic off; as so:<br></div><div><br>location = /401.html {<br> auth_basic off;<br> root G:/Files;<br> }<br><br></div>returns error 403 and 'access forbidden by rule' error. So then I added allow all; like this:<br>
<br>location = /401.html {<br> allow all;<br> auth_basic off;<br> root G:/Files;<br> }<br><br></div>This takes the user straight to the custom error 401 page without authentication.<br>
<br><br></div>The full config is:<br><br>worker_processes 1;<br><br>events {<br> worker_connections 1024;<br>}<br><br>http {<br> include mime.types;<br> default_type application/octet-stream;<br> sendfile on;<br>
<br> server {<br> satisfy any;<br> allow <a href="http://192.168.0.0/24" target="_blank">192.168.0.0/24</a>;<br> deny all;<br> auth_basic "Please login";<br> auth_basic_user_file C:\password.txt;<br>
listen 80;<br> server_name localhost;<br> root G:/Files;<br><br> location / {<br> index index.html index.php /_h5ai/server/php/index.php;<br> error_page 401 /401.html;<br>
location = /401.html {<br> allow all;<br> auth_basic off;<br> root G:/Files;<br> }<br> }<br> location ~ \.php$ {<br> include fastcgi.conf;<br>
fastcgi_pass <a href="http://127.0.0.1:9000" target="_blank">127.0.0.1:9000</a>; <br> }<br> }<br>}<br><div class="gmail_extra"><br><br><div class="gmail_quote">On 14 July 2013 19:54, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru" target="_blank">mdounin@mdounin.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br>
<div><div><br>
On Sat, Jul 13, 2013 at 02:40:14PM +0100, Michael wrote:<br>
<br>
> Hello, I was trying to set a custom error 401 page on my Nginx server<br>
> version 1.5.1 using the following methods:<br>
><br>
> error_page 401 /401.html<br>
> By itself it still displays the default site<br>
><br>
> error_page 401 <a href="http://example.com/401.html" target="_blank">http://example.com/401.html</a><br>
> Goes straight to the custom error page without a chance to authenticate<br>
><br>
> error_page 401 /401.html;<br>
> location = /401.html<br>
> {<br>
> root G:/Files;<br>
> allow all;<br>
> Also goes straight to the error page.<br>
><br>
><br>
><br>
> My entire config file:<br>
><br>
> worker_processes 1;<br>
><br>
> events<br>
> {<br>
> worker_connections 1024;<br>
> }<br>
><br>
> http<br>
> {<br>
> include mime.types;<br>
> default_type application/octet-stream;<br>
> sendfile on;<br>
><br>
> server<br>
> {<br>
> satisfy any;<br>
> allow <a href="http://192.168.0.0/24" target="_blank">192.168.0.0/24</a>;<br>
> deny all;<br>
> auth_basic "Please login";<br>
> auth_basic_user_file C:\password.txt;<br>
> listen 80;<br>
> server_name localhost;<br>
> root G:/Files;<br>
><br>
> location /<br>
> {<br>
> index index.html index.php /_h5ai/server/php/index.php;<br>
> error_page 401 /401.html;<br>
> location = /401.html<br>
> {<br>
> root G:/Files;<br>
> }<br>
> }<br>
> location ~ \.php$<br>
> {<br>
> include fastcgi.conf;<br>
> fastcgi_pass <a href="http://127.0.0.1:9000" target="_blank">127.0.0.1:9000</a>;<br>
> }<br>
> }<br>
> }<br>
><br>
><br>
> If anyone has any idea what I'm doing wrong, let me know.<br>
<br>
</div></div>Access to /401.html requires authentication, which prevents the<br>
error page configured from being returned. Try adding<br>
<br>
auth_basic off;<br>
<br>
into location /401.html.<br>
<span><font color="#888888"><br>
--<br>
Maxim Dounin<br>
<a href="http://nginx.org/en/donation.html" target="_blank">http://nginx.org/en/donation.html</a><br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</font></span></blockquote></div><br></div></div>