basic auth with rewrite issue
Maxim Dounin
mdounin at mdounin.ru
Tue Jan 19 20:35:17 MSK 2010
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.
More information about the nginx
mailing list