rewrite all locations to https except one

karolis nginx-forum at
Thu Oct 18 09:17:27 UTC 2012

Hi Everyone,

i have this problem with rewrite. As subject says i want to rewrite all
locations to https except one, that should remain http. But that one with
http isn't redirecting properly. I'm using nginx 1.2.2 version. Here's my

server {
  client_max_body_size 500M;
  listen 80;
  #rewrite ^(.*) https://$host$1 permanent;
  #rewrite ^ https://$server_name$request_uri? permanent;

  location / {
    rewrite ^(.*) https://$host$1 permanent;
    proxy_pass  http://www_serveriai_80;
    proxy_set_header Host $http_host;

  location /SomeService {
    rewrite ^(.*) http://$host$1 permanent;
    proxy_method         POST;
    proxy_pass    ;
    proxy_set_header Host $http_host;
    #proxy_redirect          default;
    #proxy_set_header        Host            $host;
    #proxy_set_header        X-Real-IP       $remote_addr;
    #proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

I really appreciate any help. Thanks!


Posted at Nginx Forum:,231948,231948#msg-231948

More information about the nginx mailing list