You can merge both servers into one and try something like this:

map $request_uri $example_org_preferred_proto {
    default "https";
    /companyBrand.do "http";
}

server {
  listen 80;
  listen 443 ssl;
  ....

  if ($scheme != $example_org_preferred_proto) {
    return 301 $example_org_preferred_proto://$server_name$request_uri;
  }
  ....
}

20.03.15 5:29, jinwon42 пишет:
Hi.

i have a setting problem.

I want all request "http" --> "https"
But, some location is "https" --> "http".

ALL Location : https
/companyBrand.do : http only

i saw error that "too many redirects"

What's problem?

----------------------------------------------------------------------------------

map $uri $example_org_preferred_proto {
        default "https";
        ~^/companyBrand.do "http";
}

server {
         listen       80;
         server_name  www.aaa.com;

        if ($example_org_preferred_proto = "https") {
                return 301 https://$server_name$request_uri;
        }

         location / {
            proxy_set_header Host                $host;
            proxy_set_header X-Real-IP            $remote_addr;
            proxy_set_header X-Forwarded-Host    $host;
            proxy_set_header X-Forwarded-Server    $host;
            proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
           proxy_set_header X-Forwarded-Proto   $scheme;
            proxy_set_header        Host $http_host;
            proxy_redirect off;
           proxy_buffering off;
            proxy_connect_timeout 60;
            proxy_read_timeout 60;
            proxy_pass   http://wwwaaacom;
         }

}


     # HTTPS server
     #
server {
         listen       443;
         server_name  www.aaa.com;

        charset utf-8;

         ssl                  on;
         ssl_certificate      D:/nginx-1.7.10/ssl/cert.pem;
         ssl_certificate_key  D:/nginx-1.7.10/ssl/key.pem;

        if ($example_org_preferred_proto = "http") {
                return 301 http://$server_name$request_uri;
        }

         location / {
            proxy_set_header Host                $host;
            proxy_set_header X-Real-IP            $remote_addr;
            proxy_set_header X-Forwarded-Host    $host;
            proxy_set_header X-Forwarded-Server    $host;
            proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
           proxy_set_header X-Forwarded-Proto   $scheme;
            proxy_set_header        Host $http_host;
            proxy_redirect off;
           proxy_buffering off;
            proxy_connect_timeout 60;
            proxy_read_timeout 60;
            proxy_pass   http://wwwaaacom;
           proxy_ssl_session_reuse off;
         }

}

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,257458,257458#msg-257458

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx


--
br,
Dmitry Pryadko

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Reply via email to