https rewrite for subdirectory only

Edho P Arief edhoprima at gmail.com
Sun Dec 26 13:17:33 MSK 2010


On Sun, Dec 26, 2010 at 5:13 PM, gunawan <satemie at gmail.com> wrote:
> Attached is the nginx.conf file, no separtion between server 80 and server
> 443.
>
> If I make separation between server 80 and server 443, it's ok.
>

That's the problem.

Also it's recommended to make separate block for http and https.

Here's what happens:

1. access http://$server_name/admin
2. matches /admin { } block, nginx redirects to https://$server_name/admin
3. matches /admin { } block, nginx redirects to https://$server_name/admin
4. repeat for infinity

Firefox sanely stops following redirection when it detects such loop.

tip: use

rewrite ^ https://$server_name$request_uri?$args permanent;

instead of

rewrite     ^(.*)   https://$server_name$1 permanent;



More information about the nginx mailing list