https on a specific directory only?

François Battail fb at francois.battail.name
Mon Dec 6 11:01:17 MSK 2010


Le lundi 06 décembre 2010 à 02:48 -0500, TECK a écrit :

> Right now, the rewrite creates a redirect loop. How can I fix that?

Use two server locations, one for http and the other one for https, like
this:

server
{
  listen 80;
  ...
  location /dir
  {
    rewrite ^/(.*) https://example.com/$1 permanent;
  }
}

server
{
  listen 443;
  ssl on;
  ...
  location /dir
  {
    auth_basic "Restricted Access";
    auth_basic_user_file htpasswd;
    ...
  }
}

Best regards




More information about the nginx mailing list