Sunday, 15 January 2012

Getting “Too many redirects” error with nginx rewrite rule -


This is nginx.conf.
There is a problem that continues to redirect.
I have a "many redirects" error
What are the problems?

Let me "/aaa/test.do" uri to http Want to
"/aaa/test.do" uri to https
Please help thank you

map $ uri $ example_org_preferred_proto {default https; ~ ^ / Aaa / test.do http; }

........

  server {80 says; Server_name www.test.com; Charset UTF-8; If ($ example_org_preferred_proto = "https") {return 301 https: // $ server_name $ request_uri; } Location / hosts $ host {proxy_set_header; Proxy_set_header X-real-IP $ remote_adder; Proxy_set_header X-Forward-Host $ host; Proxy_set_header X-Forward-Server $ host; Proxy_set_header X-Forward- $ proxy_add_x_forwarded_for; Proxy_set_header host $ http_host; Proxy_redirect closed; Proxy_buffering off; Proxy_connect_timeout 60; Proxy_read_timeout 60; Proxy_pass http: // wwwteestcom; }} # HTTPS server # server {443 Listen; Server_name www.test.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; Ssl_session_timeout 5m; Ssl_protocols SSLv3 TLSv1; ASDH: RC4 + RSA: + High:! XP: + EAUAL: AES 256-SHA; Ssl_prefer_server_ciphers ON; If ($ example_org_preferred_proto = "http") {return 301 http: // $ server_name $ request_uri; } Location / hosts $ host {proxy_set_header; Proxy_set_header X-real-IP $ remote_adder; Proxy_set_header X-Forward-Host $ host; Proxy_set_header X-Forward-Server $ host; Proxy_set_header X-Forward- $ proxy_add_x_forwarded_for; Proxy_set_header host $ http_host; Proxy_redirect closed; Proxy_buffering off; Proxy_connect_timeout 60; Proxy_read_timeout 60; Proxy_pass http: // wwwteestcom; Proxy_ssl_session_reuse turned off; } "<">  / P> 
  map $ uri $ example_org_preferred_proto {default "https"; ~ ^ / Aaa / test.do "http"; }  

In addition, I suggest defining different access and error logs for HTTP and HTTPS servers. Checking messages in those log files will help you debug the issue right away.


No comments:

Post a Comment