Redirect loop problems

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.

Update:

I just want to redirect specific URL contains /go/* to HTTP, and force
others to HTTPS.

Can you grab the http conversation from the browser or run tcpdump to
show the difference between curl and the browser? The client sends the
different thing to the server which is confirmed.

-B

Hi,

Problem solved, on conf.d directory, there is active HSTS directive,
that’s why the HTTP forcing to HTTPS, wherever I force them back to
http.

Thanks anyway.