我正在使用Ubuntu 14.04,其中apache运行在端口8080上,而Nginx运行在端口80上
我使用下面的代码来访问使用nginx与我自己的login页面进行身份validation,而不是默认login页面的Apache页面:
server { listen 80; # listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /var/www/; index index.php index.html; # Make site accessible from http://localhost/ server_name localhost; location ~ \.php$ { proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; auth_basic "Restricted"; auth_basic_user_file /etc/nginx/.htpasswd; #proxy_set_header Authorization "Basic YWRtaW46YWRtaW4="; error_page 405 =200 $uri; } }
而我的login页面是index.php:
<!DOCTYPE html> <head> <title>Login Form</title> <!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]--> </head> <body> <section class="container"> <div class="login"> <h1>Login to Apache using nginx</h1> <form method="post" action="index.html"> <p><input type="text" name="login" value="" placeholder="Username" required></p> <p><input type="password" name="password" value="" placeholder="Password" required></p> <p class="submit"><input type="submit" name="commit" value="Login"></p> </form> </div> </section> </body> </html>
我已经设置了密码:/etc/nginx/.htpasswd
我的问题是,当我访问它打开index.php的页面是正确的
它正在input正确或不正确的密码,每当它显示相同的页面说:
405不允许nginx / 1.4.6(Ubuntu)
错误的凭据是可以的,但是当我给予正确的凭据时,应该允许我访问我的页面。
请帮帮我