Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple containers per domain possible? #4

Closed
OmgImAlexis opened this issue Jan 15, 2018 · 5 comments
Closed

Multiple containers per domain possible? #4

OmgImAlexis opened this issue Jan 15, 2018 · 5 comments

Comments

@OmgImAlexis
Copy link

How would I setup multiple containers making up a single domain?

For example all containers would use example.com but with different paths /, /admin, /dashboard for each. Currently if I add multiple containers with the same domain the generator just creates multiple entries for the domain.

@lucaslorentz
Copy link
Owner

lucaslorentz commented Jan 15, 2018

You can add paths to address label. Caddy accepts with multiple config entries for same domain.

Just use:
caddy.address=example.com
caddy.address=example.com/admin
caddy.address=example.com/dashboard

Test:

docker service create --network caddy -l caddy.address=whoami.caddy-proxy -l caddy.targetport=8000 -l caddy.tls=off --name whoami0 jwilder/whoami
docker service create --network caddy -l caddy.address=whoami.caddy-proxy/path1 -l caddy.targetport=8000 -l caddy.tls=off --name whoami1 jwilder/whoami
docker service create --network caddy -l caddy.address=whoami.caddy-proxy/path2 -l caddy.targetport=8000 -l caddy.tls=off --name whoami2 jwilder/whoami
curl -H Host:whoami.caddy-proxy http://localhost:2015
curl -H Host:whoami.caddy-proxy http://localhost:2015/path1
curl -H Host:whoami.caddy-proxy http://localhost:2015/path2

@lucaslorentz
Copy link
Owner

Some info about addresses here:
https://caddyserver.com/docs/http-caddyfile

@lucaslorentz
Copy link
Owner

Feel free to ask more questions or reopen the issue.

@OmgImAlexis
Copy link
Author

So more or less the caddy.targetpath isn't needed then? I know this is a work in progress but the readme is a tad confusing.

@lucaslorentz
Copy link
Owner

lucaslorentz commented Jan 15, 2018

Actually it is still needed. because it is the path the proxy target will receive the requests.

You can combine both to achieve different results.

Redirects whole domain to whole container

address=whoami.caddy-proxy

Redirects whole domain to container path

address=whoami.caddy-proxy
targetpath=/my-path

Redirects domain path to whole container

address=whoami.caddy-proxy/path1

Redirects domain path to container path

address=whoami.caddy-proxy/path1
targetpath=/path1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants