Can't get https service to my webpage

1. Caddy version (2.4.5):

2. How I run Caddy:

<As a service on a Raspberry Pi 4 →

a. System environment:

b. Command:

<Caddy Run, Caddy Start →

Paste command here.

c. Service/unit/compose file:

CaddyFile
webcam.waterfordcityweather.com
reverse_proxy localhost:8080


d. My complete Caddyfile or JSON config:

webcam.waterfordcityweather.com
reverse_proxy localhost:8080```

### 3. The problem I'm having:
I'm trying to get an ssl https connection to my website but its not working. I have been running Caddy successfully for a few months but last week i started to have problems 


4. Error messages and/or full log output:
caddy run
2021/12/19 10:53:46.564	INFO	using adjacent Caddyfile
2021/12/19 10:53:46.567	WARN	input is not formatted with 'caddy fmt'	{"adapter": "caddyfile", "file": "Caddyfile", "line": 3}
2021/12/19 10:53:46.579	INFO	admin	admin endpoint started	{"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["127.0.0.1:2019", "localhost:2019", "[::1]:2019"]}
2021/12/19 10:53:46.580	INFO	http	server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS	{"server_name": "srv0", "https_port": 443}
2021/12/19 10:53:46.580	INFO	http	enabling automatic HTTP->HTTPS redirects{"server_name": "srv0"}
2021/12/19 10:53:46.581	INFO	tls.cache.maintenance	started background certificate maintenance	{"cache": "0x40fc0f0"}
2021/12/19 10:53:46.583	INFO	tls.cache.maintenance	stopped background certificate maintenance	{"cache": "0x40fc0f0"}
run: loading initial config: loading new config: http app module: start: tcp: listening on :443: listen tcp :443: bind: permission denied

5. What I already tried:
I have checked to see if any other services are running on ports 80 and 443 and nothing is using those ports. I have doubled checked that ports 443 and 80 are forwarded in my router. I have removed Caddy and re installed but still the same issues persist. Any suggestions how to solve this problem would be greatly appreciated.

Apologies for the format error in my post but so some reason it turned out like that and i can’t seem to edit.
5. What I already tried:
I have checked to see if any other services are running on ports 80 and 443 and nothing is using those ports. I have doubled checked that ports 443 and 80 are forwarded in my router. I have removed Caddy and re installed but still the same issues persist. Any suggestions how to solve this problem would be greatly appreciated.
Basically the error is 443 Bind Permission denied.

Thanks

Please upgrade to v2.4.6!

You can edit, find it the pencil button under your post.

If you’re running Caddy as a service, then Caddy should probably be running as the caddy user as described in the docs below. Not all users have permission to bind to low ports (ports 1024 and under).

Thanks for the reply. I think i need to start again with a clean install as i keep getting a caddy failed to start error. Would “sudo apt remove caddy” delete all instances of caddy from my system??

Its strange that a working system would stop working the way it has but thats computers right :slight_smile:

Would running Caddy in a Docker container be a better option i wonder??

Removing the apt package may not stop Caddy processes that are still running if not running as a systemd service. If you used caddy start, then you’d have an instance of Caddy running in the background not as a service. You can try running caddy stop to turn that one off if at all.

Then, make sure to stick to the systemctl commands for controlling Caddy, don’t try to directly run Caddy as your current user.

2 Likes

Going forward thats the way i will use the service and see how it works.

I have re-installed Caddy as per instructions for Raspian OS. I have followed the Tutorial in order to get an output of Hello World from localhost:2015 using both JSON and Caddyfile which was successful but not in https i might add.
Commands i have used are as per guide. caddy start, caddy stop, caddy run and caddy reload.
I have changed the Caddyfile to my domain and reverse_proxy localhost:8080 but i still get the 443 permission denied response in Caddy.
What are my options going forward to output my webpage in https?
I’m guessing in some way give access to Caddy on lower ports or change the https of 443 to something different in Caddy??
I feel like progress has been made but i just need the final step to get working.
Thank you
Edit: Just to mention i have not used systemctl commands and tried to stick to the original Tutorial

You absolutely should use systemctl commands if you plan to keep this running long-term. The tutorial is just a quick tour of how Caddy works so you learn the fundamentals. But those commands just have you directly run Caddy for ease of the tutorial.

Again, make sure you have stopped any running instances of Caddy, then enable/start the systemd service. Edit your Caddyfile at /etc/caddy/Caddyfile (the location the systemd service reads from by default).

1 Like

I followed your advice to use systemctl and it worked. Performance of the webcam is a bit choppy but this is usually fixed with a restart of the system. Should the service start up automatically after i restart or do i need to manually start from the terminal. Also i used waterfordweather.ddns.net domain not the one in my original post.
Huge thanks to Francis for the help. Sometimes we learn more about a service if its not working and i feel i did that in the last few days.

It will start automatically.

:blush:

1 Like

Just one last thing. What form would the Caddyfile take if i want to add more services i have running on different ports eg nextcloud and portainer? Would it be a case of just adding another reverse_proxy line under the one i have for 8080?

Cheers

Add more site blocks, one for each subdomain:

1 Like

I added Portainer with no issues which runs on port 9000 but i tried to add nextcloud on port 8443 but get a Client sent a HTTP request to a HTTPS server message.
Any idea what the fix for that error is??

Many thanks

Please post the config you tried, the logs, etc.

Can’t do much without exact details.

Caddy file included waterfordweather.ddns.net {
reverse_proxy localhost:8080
}
webcam.waterfordcityweather.com {
reverse_proxy localhost:9000
}
waterfordweathercam.ddns.net {
reverse_proxy localhost:8443
}
Error on webpage when trying to load

Bad Request

Your browser sent a request that this server could not understand.
Reason: You’re speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

Based on the port number being 8443, I assume the upstream is expecting an HTTPS request. Caddy’s reverse_proxy makes HTTP requests by default.

Are you sure you need to use that port? Does your upstream app have an HTTP port?

See this article, you don’t need to proxy over HTTPS when the upstream is within the same network.

2 Likes

I’m sure i could change the ports as they were set when i was creating the Docker Container within Portainer. I will just have to find the area where the ports can be edited. Any particular ports i should use?

The port number itself doesn’t matter, what matters is what that port is used for.

But by convention, 80 is HTTP, and 443 is HTTPS. So often people use 8080 and 8443 if they need a second pair of those, etc.

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