1. Caddy version (caddy version
):
v2.5.0
2. How I run Caddy:
Revers Proxy
a. System environment:
caddy runs as docker container on
Sles 15 wiht docker version: 20.10.12-ce
b. Command:
docker-compose up -d
c. Service/unit/compose file:
version: "3"
services:
caddy:
container_name: caddy
build:
context: .
dockerfile: Dockerfile
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile
- ./data/caddy:/data
- ./config:/config
ports:
- 8880:8880
- 8843:8843
networks:
- intern
Promtail docker-compose file:
version: "3"
services:
grafana:
container_name: grafana
user: "0:0"
image: /grafana/grafana:latest
restart: always
depends_on:
- prometheus
- promtail
volumes:
- ./conf/grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
- ./conf/grafana/provisioning/dashboards:/etc/grafana/provisioning/dashboards
- ./data/grafana:/var/lib/grafana
environment:
GF_SECURITY_ADMIN_USER: ${GF_SECURITY_ADMIN_USER}
GF_SECURITY_ADMIN_PASSWORD: ${GF_SECURITY_ADMIN_PASSWORD}
GF_USERS_VIEWERS_EDIT: "true"
# GF_SERVER_ROOT_URL: {{ gf_server_root_url }}
GF_SERVER_DOMAIN: example.com
GF_SERVER_ROOT_URL: https://example.com/grafana/
GF_SERVER_SERVE_FROM_SUB_PATH: "true"
networks:
- intern
promtail:
container_name: promtail
image: /grafana/promtail:latest
restart: always
environment:
- TZ=Europe/Berlin
command: -config.file=/etc/promtail-config/promtail.yml
volumes:
- ./conf/promtail/promtail.yml:/etc/promtail-config/promtail.yml
- /var/lib/docker/containers:/var/lib/docker/containers:ro
- /var/log/:/var/log/:ro
networks:
- intern
prometheus:
container_name: prometheus
user: "0"
image: prom/prometheus:latest
networks:
- intern
volumes:
- ./conf/prometheus:/etc/prometheus
- ./data/prometheus:/prometheus
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
command:
- '--storage.tsdb.retention.time=1w'
- '--storage.tsdb.retention.size=800MB'
- '--log.level=error'
- '--storage.tsdb.wal-compression'
- '--config.file=/etc/prometheus/prometheus.yml'
- '--web.enable-lifecycle'
- '--web.enable-admin-api'
- '--storage.tsdb.path=data/'
# - '--web.config.file=/etc/prometheus/web.yml'
- '--web.external-url=http://localhost:9090/prometheus/'
d. My complete Caddyfile config:
{
http_port 8880
https_port 8843
}
example.com:8843 {
handle /promtail* {
reverse_proxy promtail:9080
basicauth /promtail/* {
admin JDJhJDE0JDFrVXLHLKHKNBZWVXOy5rQ3pEdnUasd5cWxCRFZPWnkzUk10NSF2NJV2gV29T
}
}
handle /grafana* {
reverse_proxy grafana:3000
}
handle /loki* {
reverse_proxy loki:3100
basicauth /loki/* {
admin JDJDEhJDE0JDFrVXNBZWVXOEHby5rQ3pEdnU5cWxCRFZJV2gzTWxÖLÖJÖHDHV29T
}
}
handle /prometheus* {
reverse_proxy prometheus:9090
basicauth /prometheus/* {
admin JDJhJDE0JDNBJÖIOJLKJHIZWVXOE9WNEVTMFlGRn5cWxCRFZPWnkzUk10N2NJV2g29T
}
}
tls acme@company.com {
ca https://server:8001/acme/acme/directory
ca_root /usr/local/share/ca-certificates/company_bundle.crt
}
}
3. The problem I’m having:
I want to use Caddy with other ports because ports 80 and 443 are not free. How can I make Caddy not use ports 80 and 443 and instead use 8880 (for http) and 8843 (https)?
With the current configuration it does not work.
4. Error messages and/or full log output:
{"level":"error","ts":1652771760.8610604,"logger":"tls.obtain","msg":"will retry","error":"[example.com] Obtain: [example.com] solving challenges: [example.com] authorization took too long (order=https://server:8001/acme/acme/order/nDWa79wasdfadsfasfasdfaZrPRY) (ca=https://server:8001/acme/acme/directory)","attempt":7,"retrying_in":1200,"elapsed":4500.804962957,"max_duration":2592000}
example.com, is a placeholder.
5. What I already tried:
first:
{
http_port 8880
https_port 8843
}
example.com: {......config abbreviated
#####################################
second:
{
http_port 8880
https_port 8843
}
example.com:8843 {....... config abbreviated
######################################
thrid:
example.com:8843 {....... config abbreviated
6. Links to relevant resources:
example.com {
handle /promtail* {
reverse_proxy 127.0.0.1:9080
}
handle /grafana* {
reverse_proxy 127.0.0.1:3000
}
handle /loki* {
reverse_proxy 127.0.0.1:3100
}
handle /prometheus* {
reverse_proxy 127.0.0.1:9090
}
Loki config:
server:
http_listen_port: 3100
grpc_listen_port: 9095
http_path_prefix: /loki
Promtail config:
server:
http_listen_port: 9080
http_path_prefix: /promtail