Hi,
Today, I was implement redirect using return 301, here’s my snippet:
server {
listen 80;
server_name domain.tld;
error_log /dev/null;
access_log off;
return 301 https://www.domain.tld$request_uri;
}
server {
listen 80;
server_name www.domain.tld;
error_log /dev/null;
access_log off;
location ^~ /go/ {
Apache2 Backend
proxy_pass http://127.0.0.1:8080
}
location / {
return 301 https://$http_host$request_uri$is_args$query_string;
}
}
server {
listen 443 ssl spdy;
server_name domain.tld;
return 301 https://www.domain.tld$request_uri;
error_log /dev/null;
access_log off;
ssl on;
ssl_certificate bundle.crt;
ssl_certificate_key file.key;
ssl_verify_depth 2;
}
server {
listen 443 ssl spdy;
server_name www.domain.tld;
location ^~ /go/ {
return 301 http://$http_host$request_uri;
}
location / {
Apache2 Backend
proxy_pass http://127.0.0.1:8080
}
}
The problem is, if the visitor hit /go/ URL, the browser says it’s
redirect loop, but if I try curl -I command the /go/ URL, it’s
normal, and says HTTP 200.
Any hints? Really appreciate any helps.