Too many redirects wordpress

Hey guyz!
Pls help
My config
domain.com www.domain.com{
bind 127.0.0.5
proxy / 127.0.0.20:80 {
transparent
}
}
This config i see Too many redirects in my browser

Caddy default send all request to https://domain.com
I need send all request to https://www.domain.com this write in wordpress plugins

Hi @Alex_Kim,

Run curl -I 127.0.0.20:80 from the Caddy host and let us know what you get.

HTTP/1.1 200 OK
Server: nginx/1.14.1
Date: Wed, 08 May 2019 12:07:45 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Vary: Accept-Encoding,Cookie
Link: http://www.site.com/wp-json/; rel=“https://api.w.org/

Hmm.

Your Caddyfile only issues one redirect - from HTTP to HTTPS. You have configured it to respond the same to the www subdomain exactly the same as the bare domain.

The redirects are coming from the upstream nginx server. The most common issue Caddy users face is when an upstream expects a HTTPS connection but they proxy to HTTP - the client (Caddy) gets told to use HTTPS, which gets passed to the client, who ends up in an infinite loop because they connected to HTTPS in the first place.

But that response isn’t consistent with a HTTPS redirect loop - in fact, it didn’t redirect at all. So the upstream server is possibly generating the redirect loop all by itself for real clients (via JS maybe? not sure). Nothing else in the Caddyfile you posted indicates an issue.

No, direct any troubles.
I need disable redirect to https://host

If you want to disable Caddy’s automatic HTTP->S redirection, you can override the HTTP listener. You need to specify that Caddy should respond to HTTP requests the same as it does for HTTPS.

In practice, this means splitting the list of site labels into their HTTP and HTTPS components.

E.g.: from:

example.com, www.example.com

to:

http://example.com, https://example.com,
http://www.example.com, https://www.example.com

Also error ERR_TOO_MANY_REDIRECTS
My new config
http://host.com, http://www.host.com, https://host.com, https://www.host.com {
bind 127.0.0.5
proxy / 127.0.0.20:80 {
transparent
}
}

Caddy is no longer issuing any redirects to your client.

The redirects are being issued by your upstream server and passed along by Caddy.

Direct no troubles(

Also, no problems if the site does not have a redirect to www
Nginx to Nginx no this issue

I don’t think there’s any other advice I can give - there’s no other possible source of redirection. Perhaps someone else on these forums can spot something I’ve missed or has another idea to troubleshoot.

Stop

What this

curl -I https://www.site.com
HTTP/1.1 301 Moved Permanently
Content-Type: text/html; charset=UTF-8
Date: Wed, 08 May 2019 12:58:54 GMT
Location: https://www.site.com/
Server: Caddy
Server: nginx/1.14.1

This proxy answer

This direct and site work
curl -I https://www.site.com
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 08 May 2019 12:57:05 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Keep-Alive: timeout=60
X-Powered-By: PHP/5.6.37
Link: https://www.site.com/wp-json/; rel=“https://api.w.org/
Link: https://www.site.com/; rel=shortlink

This correct answer caddy from backend site no https://www.domain.cc redirected:
curl -I https://site.cc
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 08 May 2019 13:01:01 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Keep-Alive: timeout=60
Set-Cookie: PHPSESSID=qjmnugudu2882ltckcjgmgupn7; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: frk=f3b6492f89708b142cc6dc8a688be7e876ff0e60N%3B; expires=Mon, 04-Nov-2019 13:01:01 GMT; Max-Age=15552000; path=/
Set-Cookie: CSRFTOKEN=190231d15619d5228cfb2f0cb7f5af571153cf26s%3A40%3A%22a97bd7646f871cf1a0e8f0d4c80746b3cbd99ea1%22%3B; path=/

I changed backend port to 443
Redirect and loop magic disabled, also new trouble
Any https request via browser send me This messages
Client sent an HTTP request to an HTTPS server.

The presence of the second Server header indicates that this redirect was issued by the upstream server.

Change the scheme to https:// for your backend as well.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.