Comments (3)
Thanks, a good explanation is better than any elucubrations
from caddy-docker-proxy.
Look like labels of services are parsed and not label of containers in the service descriptions.
So in in generator.go:154 the service.Spec.Labels refers to labels of the service
func addServiceToCaddyFile(buffer *bytes.Buffer, service *swarm.Service) {
directives, err := parseDirectives(service.Spec.Labels, service, func() (string, error) {
Considering a compose file as follows (with swarmpit as an example):
version: '3'
services:
app:
image: swarmpit/swarmpit:latest
environment:
- SWARMPIT_DB=http://db:5984
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- swarmpit
- caddy
labels:
caddy_1.address: docker.lan:80
caddy_1.targetport: "8080"
caddy_1.tls: "off"
deploy:
placement:
constraints:
- node.role == manager
db:
image: klaemo/couchdb:2.0.0
volumes:
- /var/volumes/swarmpit:/opt/couchdb/data
networks:
- swarmpit
agent:
image: swarmpit/agent:latest
environment:
- DOCKER_API_VERSION=1.35
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- swarmpit
deploy:
mode: global
networks:
swarmpit:
driver: overlay
caddy:
external: true
To find labels back, the container spec labels should be parsed so relace generator.go:155
func addServiceToCaddyFile(buffer *bytes.Buffer, service *swarm.Service) {
directives, err := parseDirectives(service.Spec.TaskTemplate.ContainerSpec.Labels, service, func() (string, error) {
Maybe you could also skip parsing a container if it has a "com.docker.swarm.service.*" label.
That is considering that tags should be declared at the service level
from caddy-docker-proxy.
Some users doesn't use docker services, therefore reading labels from containers and proxying to container IP is useful to some people. But we don't support proxying into multiple containers yet.
I don't think they're redundant, they're complementary.
The recommended approach is to proxy to docker service, not to containers. That means your labels should on your service service, not container. Therefore you must put your labels the deploy section. According to docs: https://docs.docker.com/compose/compose-file/#labels-1
services:
app:
image: swarmpit/swarmpit:latest
environment:
- SWARMPIT_DB=http://db:5984
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
networks:
- swarmpit
- caddy
deploy:
labels:
caddy_1.address: docker.lan:80
caddy_1.targetport: "8080"
caddy_1.tls: "off"
placement:
constraints:
- node.role == manager
I don't have any problems with that setup, I run a caddy docker service with 1 or 2 instances at manager nodes, and those instances proxies to every service that I have on my swarm cluster.
Can you please try that?
from caddy-docker-proxy.
Related Issues (20)
- Multiple of the same directive HOT 2
- caddy overloaded as a random container keeps restarting HOT 11
- admin config ignored HOT 3
- caddy in docker reverse proxy to a tunnel to local machine not working
- Vaultwarden HOT 4
- HTTP/2 Rapid Reset : CVE-2023-44487 HOT 3
- Q: How to define global snippets? HOT 3
- How to make requests to reverse proxy inside docker network? HOT 7
- Service is not in same network as caddy in docker swarm
- Error using php_fastcgi directive: two Caddy blocks are created HOT 10
- sticky sessions HOT 3
- Caddy is not reading my labels HOT 4
- Latest version not available trough xcaddy build HOT 2
- Featurerequest in Readme: How to use basic auth? HOT 5
- Is it possible to automate reverse proxy entries? HOT 6
- Enable gzip globaly HOT 2
- How to enable brotli module HOT 1
- Issue redirecting from non-www to www or vice versa HOT 5
- crashed/stopped container results in a 308 loop (bug?) HOT 5
- does caddy-docker-proxy support 443/udp? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from caddy-docker-proxy.