Adding subpaths for a domain inside docker in caddy

1. The problem I’m having:

I have used caddy inside my dockerfile. I need to add paths which point to another docker container.
I am pretty sure this should not work because it has reverse proxy. Please guide me. thanks.

3. Caddy version:

2.6.4

4. How I installed and ran Caddy:

Integrated inside my dockerfile

a. System environment:

CentOS7

My complete Caddy config:

domain{
	header {
		Strict-Transport-Security "max-age=31536000; includeSubdomains; preload;"
		X-Content-Type-Options "no sniff"
		X-Frame-Options "DENY"
		Referrer-Policy "no-referrer-when-downgrade"
	}
	encode gzip
	root * /srv/public_html
	file_server

	handle /socket/* {
		reverse_proxy localhost:8081 # http://chat:8006/; 
	}
	handle_path /api/* {
		reverse_proxy localhost:8082
		# reverse_proxy http://apserver:3000/;
	}
}

the config that I had for this in nginx

localhost within a Docker container means “this container”. You’re not running any other server in that container, so that won’t work.

You should proxy to the name of your other container.

That said, you haven’t shown any actual error, so I have to guess. Please DO NOT delete any parts of the help topic template. It’s important that you completely fill it out.

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