WebFaction
Community site: login faq

Hello Sir,

I am using ubuntu 14.04, In which apache is running on port :8080 and Nginx is running on port :80

I am using following code to access apache pages using nginx with my own login page for authentication rather than default login page:

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;
        }
}

And my login page is 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>

And i have set password into : /etc/nginx/.htpasswd

My problem is when i am access the page it open index.php it is correct

it i am entering correct or incorrect password everytime it is displaying same page saying:

405 Not Allowed nginx/1.4.6 (Ubuntu)

WIth wrong credential it is ok but when i am giving right credential it should allow me to access my page.

Please help me

asked 17 Apr '15, 08:20

anandmishra
113
accept rate: 0%

edited 17 Apr '15, 08:38

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×224
×186

question asked: 17 Apr '15, 08:20

question was seen: 1,897 times

last updated: 17 Apr '15, 08:38

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM