Welcome! Log In Create A New Profile

Advanced

Re: basic auth with rewrite issue

Maxim Dounin
January 19, 2010 12:40PM
Hello!

On Tue, Jan 19, 2010 at 12:21:04PM -0500, zlegein wrote:

> Hi Merlin,
>
> Thanks for the input, but i tried your suggestion of
>
>
> server {
> listen 80;
> server_name app.dns.com;
> auth_basic "Restricted";
> auth_basic_user_file passfile;
> rewrite ^(.*)$ http://app.dns.com:7004$1 permanent;
> }
>
>
>
> But this still doesn't prompt a login. Were you suggesting that I also, drop the 'permanent'?

Rewrite directives are executed during rewrite phase, while
authorization - during access phase which happens later. So the
only solution is to change logic, i.e. to something like this:

location / {
auth_basic ...
root /path/to/nowhere;
error_page 404 = @redirect;
}

location @redirect {
rewrite ^(.*)$ http://app.dns.com:7004$1 permanent;
}

Maxim Dounin

p.s. I see a little sense in this config though, as it only
protects domain name of a real server... and it will eventually
became public anyway. So real protection should be on real
server.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

basic auth with rewrite issue

zlegein January 15, 2010 09:28PM

Re: basic auth with rewrite issue

merlin corey January 18, 2010 04:32PM

Re: basic auth with rewrite issue

zlegein January 19, 2010 12:21PM

Re: basic auth with rewrite issue

Maxim Dounin January 19, 2010 12:40PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 293
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready