Remove automatic HTTPS redirection when caddy is not running

1. Caddy version (caddy version):

Windows amd64
v2.2.0 h1:sMUFqTbVIRlmA8NkFnNt9l7s0e+0gw+7GPIrhty905A=

2. How I run Caddy:

a. System environment:

Windows Server 2019, standalone

b. Command:

caddy start

c. Service/unit/compose file:

n/a

d. My complete Caddyfile or JSON config:

Caddyfile:

/test
reverse_proxy localhost:8082

autosave.json:

{
	"apps":{
		"http":{
			"servers":{
				"srv0":{
					"listen":[":443"],
					"routes":[
						{
							"handle":[{
								"handler":"subroute",
								"routes":[{
									"handle":[{
										"handler":"reverse_proxy",
										"upstreams":[{
											"dial":"localhost:8082"
										}]
									}]
								}]
							}],
						"match":[{
						"path":["/test"]}],
						"terminal":true
						}
					]
				}
			}
		}
	}
}

3. The problem I’m having:

Before I start please know I am a beginner. I have given Caddy a try, with the intention of setting up a reverse proxy. It redirected http > https, which I didn’t necessarily want. I decided to stop using Caddy, but my http requests are still being redirected to https, even when Caddy is not running. This has broken what I had before, and I don’t know how to turn it off. Now, the only way I can access what I have on http://localhost is by using the ip address - http://192.168.0.20.

I would like to just go back to before I tried caddy, but I don’t know what’s changed or how to fix it. I have literally just put the .exe in a folder with the basic caddyfile shown above, and started it, found it wasn’t for me, and tried to remove it.

4. Error messages and/or full log output:

5. What I already tried:

I have run caddy stop, followed by caddy untrust to remove the certificate, then removed the files from C:\Users\<user>\AppData\Caddy\, but the https redirect persists.

6. Links to relevant resources:

Your browser will have cached the redirect. You’ll need to clear your browser cache to make it forget the permanent redirect Caddy served to it.

FWIW, that config doesn’t really make sense to me:

/test
reverse_proxy localhost:8082

There’s a couple issues here.

You’re specifying an exact path /test, but Caddy v2 matches paths exactly. That means that it will match /test but not /test/foo. To match more than that, then you need to append a *, like /test*.

Also, I don’t really recommend using path matchers in “site addresses” which is how this was parsed (and that’s the first time I’ve seen someone use only a path matcher as a site address :scream: I didn’t even know that would parse)

Something like this would be more reasonable, if you don’t want to test with HTTPS:

:80

reverse_proxy localhost:8082

If you want HTTPS, then you can do this (and Caddy will set up trust automatically:

localhost

reverse_proxy localhost:8082

Well like I said, I am a complete beginner, so I’m not surprised I’ve done something that doesn’t conform to best practice! I did get /test to work as shown, but I was just pointing it to a static site, and it correctly rendered the page. I’ve since implemented it as you suggested and it does indeed work correctly now. Thanks for your help :slightly_smiling_face:

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.