Comments (4)
Or perhaps to configure the loader via env var?
caddy-backend1:
image: jcowey/caddy
environment:
- CADDY_DOCKER=caddy1
networks:
- webnet2
- webnet1
volumes:
- /var/run/docker.sock:/var/run/docker.sock
from caddy-docker-proxy.
awesome thanks
from caddy-docker-proxy.
Can you provide an example of how this would work? I can't seem to get it working. I want a main caddy that handles whole-server services like portainer and matomo. Then, in a separate docker-compose, I want a caddy that handles project-specific services like php-fpm, wordpress, etc.
My thought process:
- I can't mount project-specific static files to the main caddy instance (I'd like to be able to easily add/remove/move projects without needing to change the main server configs)
- I want to keep my request chain all
caddy
. i.e. it seems like a shame to use an apache-served wordpress to gocaddy -> apache -> wordpress static files
instead I'd prefer to have the project-level caddy act as a file_server for the static files with a php_fastcgi directive pointing to the project-level php-fpm service.
This is what I've tried:
Server-level docker-compose
version: "3.8"
services:
caddy:
container_name: caddy
image: ${CADDY_IMAGE?err}
restart: unless-stopped
ports:
- 80:80
- 443:443
environment:
- CADDY_INGRESS_NETWORKS=caddy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- caddy:/data
- ./caddy/config:/config
labels:
caddy.email: ${EMAIL?err}
networks:
- caddy
logging:
driver: syslog
options:
tag: docker-caddy
matomo_db:
container_name: matomo_db
image: mariadb:${MATOMO_MARIADB_VERSION?err}
restart: unless-stopped
command: --max-allowed-packet=128MB
environment:
- MYSQL_ROOT_PASSWORD=${MATOMO_DB_ROOT_PASSWORD?err}
- MYSQL_DATABASE=${MATOMO_DB_DATABASE?err}
- MYSQL_USER=${MATOMO_DB_USER?err}
- MYSQL_PASSWORD=${MATOMO_DB_PASSWORD?err}
- MARIADB_INITDB_SKIP_TZINFO=1
volumes:
- matomo_db:/var/lib/mysql
networks:
- internal
logging:
driver: syslog
options:
tag: docker-matomo_db
matomo:
container_name: matomo
image: matomo:${MATOMO_VERSION?err}
restart: unless-stopped
environment:
- MATOMO_DATABASE_HOST=matomo_db
- MATOMO_DATABASE_ADAPTER=mysql
- MATOMO_DATABASE_TABLES_PREFIX=matomo_
- MATOMO_DATABASE_USERNAME=${MATOMO_DB_USER?err}
- MATOMO_DATABASE_PASSWORD=${MATOMO_DB_PASSWORD?err}
- MATOMO_DATABASE_DBNAME=${MATOMO_DB_DATABASE?err}
- PHP_MEMORY_LIMIT=2048M
volumes:
- matomo:/var/www/html/
- ./matomo/config:/var/www/html/config:rw
labels:
caddy: ${MATOMO_URL?err}
caddy.reverse_proxy: "{{upstreams}}"
networks:
- caddy
- internal
depends_on:
- matomo_db
logging:
driver: syslog
options:
tag: docker-matomo
volumes:
caddy:
matomo:
matomo_db:
networks:
caddy:
name: caddy
internal:
name: server_internal
external: false
That is working fine and I can access the matomo dashboard.
Project-level docker-compose
version: "3.8"
services:
caddy:
container_name: ${PROJECT_NAME?err}_caddy
image: ${CADDY_IMAGE?err}
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- caddy:/data
- ./files:/var/www
environment:
- CADDY_DOCKER_LABEL_PREFIX=project-caddy
labels:
caddy: ${DOMAIN?err}
caddy.reverse_proxy: "{{upstreams 80}}"
project-caddy: localhost
project-caddy.root: "* /var/www/public"
project-caddy.file_server:
project-caddy.encode: gzip
project-caddy.php_fastcgi: "php-fpm:9000"
networks:
- caddy
- internal
logging:
driver: syslog
options:
tag: docker-${PROJECT_NAME?err}-caddy
php-fpm:
container_name: ${PROJECT_NAME?err}_php
image: php:${PHP_VERSION?err}-fpm
restart: unless-stopped
volumes:
- ./files:/var/www
networks:
- internal
logging:
driver: syslog
options:
tag: docker-${PROJECT_NAME?err}-caddy
volumes:
caddy:
name: ${PROJECT_NAME?err}_caddy
networks:
caddy:
external: true
internal:
name: ${PROJECT_NAME?err}_internal
external: false
To clarify, in my .env file I have CADDY_IMAGE=lucaslorentz/caddy-docker-proxy:ci-alpine
and my ./files
directory currently has a public
folder that just currently just has index.html and info.php until I get this working.
from caddy-docker-proxy.
@revnelson this is a post from 2018, from before Caddy v2 existed. Caddy v2 was a complete rewrite, so everything here is no longer relevant. Please open a new issue.
from caddy-docker-proxy.
Related Issues (20)
- `Failed to get Container Caddyfile` HOT 3
- Run server NOT in docker? (but controller in docker) HOT 1
- Add --pidfile flag to docker-proxy
- wildcard not working HOT 2
- IPv6 Logging not working HOT 2
- Caddy 2.8 Final Release HOT 2
- Trouble with generic logging snippet import HOT 2
- Expose caddy admin 2019
- Custom images HOT 2
- How to local test caddy with whoami HOT 1
- Changing HTTP status code rewrite - is that possible using labels? HOT 1
- Simple redirect to custom 404.html (static site)
- Global options seems not working in caddy-docker-proxy itself HOT 1
- basic_auth label is still being written to caddyfile as basicauth which spams logs HOT 2
- Using the upstreams template in a snippet with arguments
- caddy-docker-proxy as file server ? HOT 1
- Is it possible to inject directives in an existing service? HOT 4
- Using CDP as a reverse proxy for non-docker services - is it possible? HOT 1
- How to enable caddy-docker-proxy in a new build? HOT 2
- Help to convert a snippet to labels HOT 9
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.