Hello, I was trying to set a custom error 401 page on my Nginx server
version 1.5.1 using the following methods:
error_page 401 /401.html
By itself it still displays the default site
error_page 401 http://example.com/401.html
Goes straight to the custom error page without a chance to authenticate
error_page 401 /401.html;
location = /401.html
{
root G:/Files;
allow all;
Also goes straight to the error page.
My entire config file:
worker_processes 1;
events
{
worker_connections 1024;
}
http
{
include mime.types;
default_type application/octet-stream;
sendfile on;
server
{
satisfy any;
allow 192.168.0.0/24;
deny all;
auth_basic "Please login";
auth_basic_user_file C:\password.txt;
listen 80;
server_name localhost;
root G:/Files;
location /
{
index index.html index.php /_h5ai/server/php/index.php;
error_page 401 /401.html;
location = /401.html
{
root G:/Files;
}
}
location ~ .php$
{
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
}
If anyone has any idea what I’m doing wrong, let me know.
Kind regards,
Michael
Hello,in nginx1 use proxy_pass to nginx2,when http method is get that is
ok,but when http method is post ,nginx2 has no access log,nginx1’s
response status is 302; help please,thank you!!
nginx-config details:
nginx1-config:
server { listen 80; server_name ocs.aliyun.test; access_log
“pipe:/usr/sbin/cronolog /system/logs/ocs.%Y-%m-%d.log” aliyun_com;
location /widget/ { proxy_pass http://openwidget.aliyun.test/;
proxy_redirect http://openwidget.aliyun.test/ /widget/; } }
nginx2-config:
server { listen 80; server_name openwidget.aliyun.test; access_log
“pipe:/usr/sbin/cronolog /system/logs/openwidget.%Y-%m-%d.log”
aliyun_com; location / { proxy_pass
http://127.0.0.1:38782/openWidget/; proxy_redirect
http://openwidget.aliyun.test/openWidget/ /; } }
Added auth_basic off; as so:
location = /401.html {
auth_basic off;
root G:/Files;
}
returns error 403 and ‘access forbidden by rule’ error. So then I added
allow all; like this:
location = /401.html {
allow all;
auth_basic off;
root G:/Files;
}
This takes the user straight to the custom error 401 page without
authentication.
The full config is:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
satisfy any;
allow 192.168.0.0/24;
deny all;
auth_basic "Please login";
auth_basic_user_file C:\password.txt;
listen 80;
server_name localhost;
root G:/Files;
location / {
index index.html index.php /_h5ai/server/php/index.php;
error_page 401 /401.html;
location = /401.html {
allow all;
auth_basic off;
root G:/Files;
}
}
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
}
Hello!
On Sat, Jul 13, 2013 at 02:40:14PM +0100, Michael wrote:
location = /401.html
{
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
}
}
If anyone has any idea what I’m doing wrong, let me know.
Access to /401.html requires authentication, which prevents the
error page configured from being returned. Try adding
auth_basic off;
into location /401.html.
–
Maxim D.
http://nginx.org/en/donation.html