Running Caddy and Restreamer (Docker Container) without port conflicts

1. Caddy version (caddy version):

2.4.3

2. How I run Caddy:

Raspberry pi 4

a. System environment:

Raspian

b. Command:

Caddy run

Paste command here.

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

waterfordweather.ddns.net:8080

3. The problem I’m having:

I’m trying to get https on a website which runs on port 8080 via a docker container called restreamer.
I can get a cert no problem when i leave out the 8080 in the address but i need that port to load the settings page.
What do in need to change in order to run the landing page in https? Also in order to embed the images and player to any website in https

4. Error messages and/or full log output:

Port conflict errors

5. What I already tried:

Tried to change the port that caddy runs on without success

6. Links to relevant resources:

You haven’t properly filled out the topic template.

What does your Caddyfile look like? What’s in your logs? What commands are you running to run your Docker containers, or what’s in your docker-compose.yml?

Caddy requires ports 80 and 443 to properly solve ACME challenges.

Caddy file is just the domain name
waterfordweather.ddns.net:8080

Caddy is not running in Docker its running on the root of the Raspberry pi 4 system. Debian based.

The Restreamer webcam container is running on Docker and available at the address above but i need the output to be https to embed on my website so thats why i’m using Caddy.
When i run Caddy run i get the following
2021/08/15 14:31:53.799 INFO using adjacent Caddyfile
2021/08/15 14:31:53.802 WARN input is not formatted with ‘caddy fmt’ {“adapter”: “caddyfile”, “file”: “Caddyfile”, “line”: 3}
2021/08/15 14:31:53.805 INFO admin admin endpoint started {“address”: “tcp/localhost:2019”, “enforce_origin”: false, “origins”: [“localhost:2019”, “[::1]:2019”, “127.0.0.1:2019”]}
2021/08/15 14:31:53.806 INFO tls.cache.maintenance started background certificate maintenance {“cache”: “0x2ccba90”}
2021/08/15 14:31:53.806 INFO http enabling automatic HTTP->HTTPS redirects {“server_name”: “srv0”}
2021/08/15 14:31:53.807 INFO tls.cache.maintenance stopped background certificate maintenance {“cache”: “0x2ccba90”}
run: loading initial config: loading new config: http app module: start: tcp: listening on :8080: listen tcp :8080: bind: address already in use.

Basically can i get Caddy to output that address in ssl/https?
Cheers

That’s not a valid Caddyfile. You need to tell Caddy to do something for that domain. Probably using the reverse_proxy directive.

I think you have a misunderstanding of how proxying works.

If you have a service already listening on port 8080, then you can’t run another program that tries to also listen on that port. Only one process can receive data in that port at any given time.

Caddy requires ports 80 and 443 to properly serve HTTP and HTTPS content (80 and 443 are the default ports for HTTP and HTTPS respectively) and to solve ACME challenges (i.e. prove to Let’s Encrypt that you own/control that domain, so they can trust your server and give it a signed certificate).

What you should do is have Caddy proxy requests it receives on port 443 to send them to your existing service on port 8080.

This would look like this:

waterfordweather.ddns.net {
	reverse_proxy localhost:8080
}

This article should probably clarify some points:

2 Likes

(Minor nit: it is a valid Caddyfile, it just won’t do anything particularly useful.)

Thanks for the information. I will try that command in the Caddyfile to see if it works.

Just an update to let people know the reverse proxy command in the Caddyfile worked. I’m now running my webcam using restreamer in https thanks to Caddy. Big thanks to everyone at Caddy and helpers on the forum

1 Like

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