Rewrite non-ssl to ssl except for given location

Adnan RIHAN adnan at
Sun Apr 15 15:22:03 UTC 2012

Hi everybody,

I'm using an internal proxy for one of my websites (just a PHP script which does a curl request for a given script).

I've forced every non-ssl location to ssl with this:
> rewrite ^/(.*) https://$host/$1 permanent;

The thing is that my scripts doesn't need SSL as it's internal, so I want to force SSL except for a given location:
> location = /includes/api.php {
> }  
> rewrite ^/(.*) https://$host/$1 permanent;

Unfortunately, this isn't enough and queries to /includes/api.php?foo=bar still sends me a 301 redirect.
Am I missing something ?
Thanks for your help.
Cordialement, Adnan RIHAN.
Président-Fondateur de l'association (de loi 1901) Virtual-Info (, hébergeur Web et Serveurs de Jeux.
Consultant ( Supérieur en Informatique de Gestion.
Ambassadeur Qt ( (Projet Tag-PG (

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list