<div dir="ltr"><div style="font-family:arial,sans-serif;font-size:13px">Hello, I was trying to set a custom error 401 page on my Nginx server version 1.5.1 using the following methods:</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">error_page 401 /401.html<br></div><div style="font-family:arial,sans-serif;font-size:13px">By itself it still displays the default site<br></div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">error_page 401 <a href="http://example.com/401.html" target="_blank">http://example.com/401.html</a><br></div><div style="font-family:arial,sans-serif;font-size:13px">
Goes straight to the custom error page without a chance to authenticate</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><div>error_page 401 /401.html;</div>
<div>location = /401.html</div><div> {</div><div> root G:/Files;</div><div> allow all;</div></div><div style="font-family:arial,sans-serif;font-size:13px">Also goes straight to the error page.<br>
</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
My entire config file:</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">worker_processes 1;</div><div style="font-family:arial,sans-serif;font-size:13px">
<br></div><div style="font-family:arial,sans-serif;font-size:13px">events </div><div style="font-family:arial,sans-serif;font-size:13px">{</div><div style="font-family:arial,sans-serif;font-size:13px"> worker_connections 1024;</div>
<div style="font-family:arial,sans-serif;font-size:13px">}</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">http </div><div style="font-family:arial,sans-serif;font-size:13px">
{</div><div style="font-family:arial,sans-serif;font-size:13px"> include mime.types;</div><div style="font-family:arial,sans-serif;font-size:13px"> default_type application/octet-stream;</div><div style="font-family:arial,sans-serif;font-size:13px">
sendfile on;</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"> server </div><div style="font-family:arial,sans-serif;font-size:13px"> {</div>
<div style="font-family:arial,sans-serif;font-size:13px"> satisfy any;</div><div style="font-family:arial,sans-serif;font-size:13px"> allow <a href="http://192.168.0.0/24" target="_blank">192.168.0.0/24</a>;</div>
<div style="font-family:arial,sans-serif;font-size:13px"> deny all;</div><div style="font-family:arial,sans-serif;font-size:13px"> auth_basic "Please login";</div><div style="font-family:arial,sans-serif;font-size:13px">
auth_basic_user_file C:\password.txt;</div><div style="font-family:arial,sans-serif;font-size:13px"> listen 80;</div><div style="font-family:arial,sans-serif;font-size:13px"> server_name localhost;</div>
<div style="font-family:arial,sans-serif;font-size:13px"> root G:/Files;</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"> location / </div>
<div style="font-family:arial,sans-serif;font-size:13px"> {</div><div style="font-family:arial,sans-serif;font-size:13px"> index index.html index.php /_h5ai/server/php/index.php;</div><div style="font-family:arial,sans-serif;font-size:13px">
<span style="white-space:pre-wrap"> </span>error_page 401 /401.html;</div><div style="font-family:arial,sans-serif;font-size:13px"> location = /401.html</div><div style="font-family:arial,sans-serif;font-size:13px">
<span style="white-space:pre-wrap"> </span>{</div><div style="font-family:arial,sans-serif;font-size:13px"><span style="white-space:pre-wrap"> </span>root G:/Files;</div><div style="font-family:arial,sans-serif;font-size:13px">
<span style="white-space:pre-wrap"> </span>}</div><div style="font-family:arial,sans-serif;font-size:13px"> }</div><div style="font-family:arial,sans-serif;font-size:13px"> location ~ \.php$ </div>
<div style="font-family:arial,sans-serif;font-size:13px"> {</div><div style="font-family:arial,sans-serif;font-size:13px"> include fastcgi.conf;</div><div style="font-family:arial,sans-serif;font-size:13px">
fastcgi_pass <a href="http://127.0.0.1:9000/" target="_blank">127.0.0.1:9000</a>; </div><div style="font-family:arial,sans-serif;font-size:13px"> }</div><div style="font-family:arial,sans-serif;font-size:13px">
}</div><div style="font-family:arial,sans-serif;font-size:13px">}</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">
If anyone has any idea what I'm doing wrong, let me know.</div><div style="font-family:arial,sans-serif;font-size:13px"><br></div><div style="font-family:arial,sans-serif;font-size:13px">Kind regards,</div><div style="font-family:arial,sans-serif;font-size:13px">
Michael</div></div>