I am attempting to access the whoami container running on my remote server, but can only get as far as a "404 page not found" error. I get the same result when attempting to access the traefik dashboard.
My docker-compose.yml:
version: "3.7"
services:
traefik:
image: traefik:v2.3.0
container_name: traefik
restart: unless-stopped
command: # CLI arguments
## Globals
- "--global.checkNewVersion=false"
- "--global.sendAnonymousUsage=false"
## Entrypoint Settings - https://docs.traefik.io/routing/entrypoints/#configuration ##
- "--entrypoints.http.address=:80"
- "--entrypoints.http.http.redirections.entryPoint.to=https"
- "--entrypoints.http.http.redirections.entryPoint.scheme=https"
- "--entrypoints.https.address=:443"
## API Settings
- "--api=true"
- "--api.dashboard=true"
- "--log=true"
- "--log.level=DEBUG" # (Default: error) DEBUG, INFO, WARN, ERROR, FATAL, PANIC
- "--providers.docker=true"
- "--providers.docker.watch=true"
- "--providers.docker.exposedByDefault=false"
## Certificate Settings (Let's Encrypt) - https://docs.traefik.io/https/acme/#configuration-examples ##
- "--certificatesresolvers.mytlschallenge.acme.caServer=https://acme-staging-v02.api.letsencrypt.org/directory" # TBD - TESTING
networks:
- frontend
ports:
- "80:80"
- "443:443"
- "8080:8080"
security_opt:
- "no-new-privileges:true" # https://docs.docker.com/engine/reference/run/#security-configuration
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "$USERDIR/ctmp/acme/acme.json:/acme.json:rw" # cert location - you must touch this file and change permissions to 600
labels:
- "traefik.enable=true"
## HTTP Routers
- "traefik.http.routers.traefik-rtr.rule=HostHeader(`traefik.${DOMAIN}`)"
- "traefik.http.routers.traefik-rtr.entrypoints=https"
- "traefik.http.routers.traefik-rtr.service=api#internal"
whoami:
image: "traefik/whoami"
container_name: "simple-service"
networks:
- frontend
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=HostHeader(`whoami.${DOMAIN}`)"
- "traefik.http.routers.whoami.entrypoints=http"
networks:
frontend:
external: true
$USERDIR and $DOMAIN are defined in my .env file.
All of the traefik logs are info or debug level with no errors appearing.
I don't have the time right now but here is a quick code rewrite, but not tested.
It is just a slightly different method. But I think it leads to the same goal.
You must include your ENV file
traefik.http.routers.api.rule=HostHeader to =Host(`...). Whereby it is strange and should also work with HostHeader. Link
With this base you can now customize it. I use the HTTP chalange, but with the TLS chalange it should work.
version: "3.7"
services:
traefik:
image: traefik:v2.3.0
container_name: traefik
restart: unless-stopped
env_file:
- .env
command: # CLI arguments
## Globals
- "--global.checkNewVersion=false"
- "--global.sendAnonymousUsage=false"
## Entrypoint Settings - https://docs.traefik.io/routing/entrypoints/#configuration ##
- "--entrypoints.http.address=:80"
- "--entrypoints.https.address=:443"
## API Settings
- "--api=true"
- "--api.insecure=false"
- "--api.dashboard=true"
- "--log.level=DEBUG" # (Default: error) DEBUG, INFO, WARN, ERROR, FATAL, PANIC
- "--providers.docker=true"
- "--providers.docker.exposedByDefault=false"
## Certificate Settings
- "--certificatesresolvers.myresolver.acme.httpchallenge=true"
- "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=http"
- "--certificatesresolvers.myresolver.acme.email=YOUR-EMAIL#your-domain.com"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
networks:
- frontend
ports:
- "80:80"
- "443:443"
- "8080:8080"
security_opt:
- "no-new-privileges:true" # https://docs.docker.com/engine/reference/run/#security-configuration
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./letsencrypt:/letsencrypt"
labels:
- "traefik.enable=true"
## HTTP Routers
- "traefik.http.routers.api.rule=Host(`traefik.${DOMAIN}`)"
- "traefik.http.routers.api.entrypoints=https"
- "traefik.http.routers.api.service=api#internal"
- "traefik.http.routers.api.tls.certresolver=myresolver"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
- "traefik.http.routers.redirect.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.redirect.middlewares=redirect-to-https"
whoami:
image: traefik/whoami
container_name: simple-service
networks:
- frontend
labels:
- "traefik.enable=true"
- "traefik.http.routers.whoami.rule=Host(`whoami.${DOMAIN}`)"
- "traefik.http.routers.whoami.entrypoints=https"
- "traefik.http.routers.whoami.tls.certresolver=myresolver"
networks:
frontend:
external: true
Related
traefik rule not redirecting requests made to "localhost/api" to backend container
Whenever I change the backend
- "traefik.http.routers.api.rule=Host(`localhost`) && PathPrefix(`/api`)"
to Host('localhost') I can access the application at localhost but after adding this rule, whenever I go to localhost/api , it leads me to frontend and opens html page
version: '3'
volumes:
myvol2:
external: false
services:
traefik:
image: "traefik:v2.6"
command:
#- "--log.level=DEBUG"
- "--api.insecure=true"
- "--api.dashboard=true"
- "--api.debug=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.api.address=:5000"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443" # new
ports:
- "80:80"
- "5000:5000"
- "443:443" # new
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
api:
image: "myimagename"
ports:
- '5000'
scale: 1
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`localhost`) && PathPrefix(`/api`)"
- "traefik.http.routers.api.entrypoints=web"
- "traefik.http.services.api.loadbalancer.server.port=5000"
volumes:
- /app/node_modules
- ./server:/app
- myvol2:/resources/static/assets/uploads # Volume
environment:
- PORT=5000
web:
image: "myfrontendimage"
stdin_open: true
scale: 1
ports:
- '3000'
environment:
- CHOKIDAR_USEPOLLING=true
- CI=true
labels:
- "traefik.enable=true"
- "traefik.http.routers.web.rule=Host(`localhost`)"
- "traefik.http.routers.web.entrypoints=web"
- "traefik.http.services.web.loadbalancer.server.port=3000"
volumes:
- /app/node_modules
- ./client:/app
Tried redirecting the Tried almost all combinations of route, even tried adding regexp for matching localhost/api.
With my current nginx setup,
I have :
location /api{
rewrite /api/(.*) /$1 break;
proxy_pass http://api;
}
in my default.conf,
Trying to migrate to traefik but the requests to localhost/api are not reaching
Your configuration seems to be fine. In your question you have a bunch of placeholder values, so it's not actually possible to test your docker-compose.yaml, but we can produce a runnable version like this:
services:
traefik:
image: "traefik:v2.9"
command:
- "--api.insecure=true"
- "--api.dashboard=true"
- "--api.debug=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
# The port mappings here are to avoid conflicts with other services
# on my system
ports:
- "7080:80"
- "7443:443"
- "7090:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
api:
# Note that we don't need a `ports` configuration here because we're
# not publish any ports to the host (all access will be via the
# frontend proxy).
image: "docker.io/traefik/whoami:latest"
command:
- --name=API
- --port=5000
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`localhost`) && PathPrefix(`/api`)"
- "traefik.http.routers.api.entrypoints=web"
- "traefik.http.services.api.loadbalancer.server.port=5000"
web:
image: "docker.io/traefik/whoami:latest"
command:
- --name=WEB
- --port=3000
labels:
- "traefik.enable=true"
- "traefik.http.routers.web.rule=Host(`localhost`)"
- "traefik.http.routers.web.entrypoints=web"
- "traefik.http.services.web.loadbalancer.server.port=3000"
The significant changes here are:
I'm using Traefik v2.9 (because why use an older release?)
I've replaced all your images with docker.io/traefik/whoami, which gives us a simple endpoint for testing.
With the above configuration, a request to http://localhost hits the "web" container:
$ curl localhost:7080
Name: WEB
[...]
Whereas a request to http://localhost/api hits the "api" container:
$ curl localhost:7080/api
{...., "name": "API"}
(We're getting a JSON response in the second case because we're hitting the /api path on the whoami container.)
Finally, got the traefik /api to redirect to the other backend container with the following set up
The primary issue was that even though it redirects to the container, it did not strip the /api prefix, so the API route was getting messed up
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=PathPrefix(`/api/`)"
- "traefik.http.routers.api.service=api"
- "traefik.http.services.api.loadbalancer.server.port=5000"
- "traefik.http.middlewares.api.stripprefix.prefixes=/api"
- "traefik.http.middlewares.api.stripprefix.forceSlash=false"
- "traefik.http.routers.api.middlewares=api"
I'm trying to get self hosted Gitea instance and a self hosted drone.io (version 2) instance to work together.
Gitea is running. I added a drone.io OAuth application in Gitea settings with "https://drone.mydomain/login" as url.
When I open drone.io url (https://drone.mydomain) in my browser I get a welcome page. Clicking the "Continue" button I get a message after a few seconds:
Post "https://gitea.mydomain/login/oauth/access_token": dial tcp 192.168.82.146:443: connect: no route to host
Logs in gitea look normal to me:
router: completed GET /login/oauth/authorize?client_id=f999e784-f351-43db-a491-d0a90d8a2c57&redirect_uri=https%3A%2F%2Fdrone.mydomain%2Flogin&response_type=code&state=b80704bb7b4d7c03 for 192.168.82.40:0, 303 See Other in 20.2ms # auth/oauth.go:361(auth.AuthorizeOAuth)
Logs in dronio container look as expected:
{
"level": "error",
"msg": "oauth: cannot exchange code: gta_cgbk727fe32plbnahnok4u3543ql2xv4q3fvnfgaxwtkknafb5gq: Post \"https://gitea.mydomain/login/oauth/access_token\": dial tcp 192.168.82.146:443: connect: no route to host",
"time": "2022-12-31T01:39:18+01:00"
}
To me it looks like "https://gitea.mydomain/login/oauth/access_token" was resolved via DNS and the IP was inserted for the domain but some header informations are missing so that Traefik does not know to which service to forward the request.
I added dns information (gitea, local DNS) to drone service which did not help.
Here is my docker-compose file:
version: '3.3'
services:
gitea-db:
# Left out to shorten this file
gitea:
image: gitea/gitea:latest
container_name: gitea
restart: always
depends_on:
gitea-db:
condition: service_started
gitea-cache:
condition: service_healthy
secrets:
- mysql_user
- mysql_user_password
volumes:
- /share/Container/gitea/data:/data
environment:
- APP_NAME=Gitea
- USER_UID=1000
- USER_GID=1000
- USER=git
- HTTP_PORT=3000
- DOMAIN=`${GITEA_URL}`
- SSH_DOMAIN=`${GITEA_URL}`
- SSH_PORT=222
- SSH_LISTEN_PORT=22
- DB_TYPE=mysql
- DB_HOST=gitea-db:3306
- DB_NAME=${MYSQL_DATABASE}
- DB_USER_FILE=/run/secrets/mysql_user
- DB_PASSWD_FILE=/run/secrets/mysql_user_password
- TZ=Europe/Berlin
- RUN_MODE=prod
- APP_NAME=My Gitea
- REQUIRE_SIGNIN_VIEW=true
- ROOT_URL=`https://${GITEA_URL}`
- GITEA__cache__ENABLED=true
- GITEA__cache__ADAPTER=redis
- GITEA__cache__HOST=redis://gitea-cache:6379/0?pool_size=100&idle_timeout=180s
- GITEA__cache__ITEM_TTL=24h
labels:
- "traefik.enable=true"
- "traefik.http.routers.gitea.entrypoints=web-secure"
- "traefik.http.routers.gitea.rule=Host(`${GITEA_URL}`)"
- "traefik.http.routers.gitea.tls=true"
- "traefik.http.routers.gitea.service=gitea-service"
- "traefik.http.services.gitea-service.loadbalancer.server.port=3000"
- "traefik.tcp.routers.gitea-ssh.rule=HostSNI(`*`)"
- "traefik.tcp.routers.gitea-ssh.entrypoints=ssh"
- "traefik.tcp.routers.gitea-ssh.service=gitea-ssh-svc"
- "traefik.tcp.services.gitea-ssh-svc.loadbalancer.server.port=22"
networks:
- traefik_proxy
- default
gitea-cache:
# Left out to shorten this file
droneio:
image: drone/drone:2
container_name: droneio
restart: unless-stopped
dns: # trying to fix my issue by adding this section
- 192.168.82.153 # local DNS
- gitea
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /share/Container/drone/data:/data
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_SERVER_HOST=${DRONE_URL}
- DRONE_SERVER_PROTO=https
- DRONE_RPC_SECRET=${PRC_SECRET}
- DRONE_GITEA_SERVER=https://${GITEA_URL}/
- DRONE_GITEA_CLIENT_ID=${GITEA_CLIENT_ID} # need to change to docker secret
- DRONE_GITEA_CLIENT_SECRET=${GITEA_CLIENT_SECRET} # need to change to docker secret
- DRONE_LOGS_PRETTY=true
- DRONE_LOGS_COLOR=true
- DRONE_DEBUG=true
- DRONE_TRACE=true
labels:
- traefik.enable=true
- traefik.http.routers.drone-http.entrypoints=web
- traefik.http.routers.drone-http.rule=Host(`${DRONE_URL}`)
- traefik.http.routers.drone.entrypoints=web-secure
- traefik.http.routers.drone.rule=Host(`${DRONE_URL}`)
- traefik.http.routers.drone.tls=true
networks:
- traefik_proxy
- default
depends_on:
- gitea
drone-runner:
image: drone/drone-runner-docker:1
container_name: drone-runner
restart: unless-stopped
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_RPC_PROTO=https
- DRONE_RPC_HOST=${DRONE_URL}
- DRONE_RPC_SECRET=${PRC_SECRET}
- DRONE_RUNNER_CAPACITY=1
- DRONE_RUNNER_NAME=drone-runner-1
ports:
- 3000:3000
depends_on:
- droneio
networks:
- default
secrets:
mysql_root_password:
file: ./secrets/mysql_root_pw.txt
mysql_user:
file: ./secrets/mysql_user.txt
mysql_user_password:
file: ./secrets/mysql_user_pw.txt
networks:
traefik_proxy:
external:
name: traefik_proxy
default:
driver: bridge
I'd be grateful if somebody has a hint. Thank you in advance.
I tired to setup local instance of of gitea and drone.io using docker-compose.
I use traefik routing for custom local subdomains .docker.localdev, dnsmasq and locally-trusted certificates with mkcert as described in this article:
https://medium.com/soulweb-academy/docker-local-dev-stack-with-traefik-https-dnsmasq-locally-trusted-certificate-for-ubuntu-20-04-5f036c9af83d
I added OAuth2 application in gitea and added redirect URI https://droneio.docker.localdev/login. Client ID & Client Secret added to docker-compose.yaml.
When i authenticate Drone it results in error after final redirection:
Login Failed. Post "https://gitea.docker.localdev/login/oauth/access_token": dial tcp: lookup gitea.docker.localdev on 127.0.0.11:53: no such host
I only managed to get working setup using private LAN addresses with ports instead of treafik subdomains.
How to configure docker to make treafik subdomains accessible between these containers?
My current docker-compose.yaml:
---
version: '3'
services:
gitea:
image: gitea/gitea
environment:
- SSH_DOMAIN=gitea.docker.localdev
- SSH_PORT=222
- SSH_LISTEN_PORT=22
- ROOT_URL=gitea.docker.localdev
volumes:
- ./gitea_data:/data
labels:
- "traefik.enable=true"
- "traefik.http.routers.gitea-web.entrypoints=web"
- "traefik.http.routers.gitea-web.rule=Host(`gitea.docker.localdev`)"
- "traefik.http.routers.gitea-web.service=gitea-web-svc"
- "traefik.http.services.gitea-web-svc.loadbalancer.server.port=3000"
- traefik.http.routers.gitea-http.middlewares=gitea-https
- traefik.http.middlewares.gitea-https.redirectscheme.scheme=https
- traefik.http.routers.gitea-https.entrypoints=websecure
- traefik.http.routers.gitea-https.rule=Host(`gitea.docker.localdev`)
- traefik.http.routers.gitea-https.tls=true
- "traefik.tcp.routers.gitea-ssh.rule=HostSNI(`*`)"
- "traefik.tcp.routers.gitea-ssh.entrypoints=ssh"
- "traefik.tcp.routers.gitea-ssh.service=gitea-ssh-svc"
- "traefik.tcp.services.gitea-ssh-svc.loadbalancer.server.port=22"
networks:
- web
droneio:
image: drone/drone:latest
container_name: droneio
restart: unless-stopped
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /var/docker/droneio-data:/data
environment:
- DRONE_SERVER_HOST=droneio.docker.localdev
- DRONE_SERVER_PROTO=https
- DRONE_RPC_SECRET=4810ef8120663ffa960dfa1d78c5d437
# Gitea Config
- DRONE_GITEA_SERVER=https://gitea.docker.localdev/
- DRONE_GITEA_CLIENT_ID=0828a8c9-02f5-459e-9804-8b37ea0b3eb7
- DRONE_GITEA_CLIENT_SECRET=gto_p6pydy3m5j6jetbcyz6oqzoslrpil7evsi7xbx5xgwngxywn6scq
- DRONE_LOGS_PRETTY=true
- DRONE_LOGS_COLOR=true
- DRONE_DEBUG=true
- DRONE_TRACE=true
labels:
- traefik.enable=true
- traefik.http.routers.droneio-http.entrypoints=web
- traefik.http.routers.droneio-http.rule=Host(`droneio.docker.localdev`)
- traefik.http.routers.droneio-http.middlewares=droneio-https
- traefik.http.middlewares.droneio-https.redirectscheme.scheme=https
- traefik.http.routers.droneio-https.entrypoints=websecure
- traefik.http.routers.droneio-https.rule=Host(`droneio.docker.localdev`)
- traefik.http.routers.droneio-https.tls=true
networks:
- web
depends_on:
- gitea
drone-runner:
image: drone/drone-runner-docker:1
container_name: drone-runner
restart: unless-stopped
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /var/run/docker.sock:/var/run/docker.sock
environment:
- DRONE_RPC_PROTO=https
- DRONE_RPC_HOST=droneio.docker.localdev
- DRONE_RPC_SECRET=4810ef8120663ffa960dfa1d78c5d437 # random string generated by openssl rand -hex 16
- DRONE_RUNNER_CAPACITY=2
- DRONE_RUNNER_NAME=droneio.docker.localdev
ports:
- 3500:3000
depends_on:
- droneio
networks:
web:
external: true
volumes:
git:
db:
The drone container has no way to be aware of what is happening in the gitea container. That does include any locally set up dns records, since your are not setting those in a globally available way. You need to add a way for your drone container to use the gitea container, with traefik included, as your dns resolver.
Docker compose let's you do that using the following structure:
services:
droneio:
dns:
- 8.8.8.8
- gitea
My working docker-compose.yaml
---
version: '3'
volumes:
git:
db:
services:
gitea:
image: gitea/gitea:latest
ports:
# - '22:22'
- '3555:3000'
restart: unless-stopped
environment:
- SSH_DOMAIN=gitea.docker.localdev
- SSH_PORT=222
- SSH_LISTEN_PORT=22
volumes:
- ${DOCKER_DATA_DIR}/gitea_data:/data
labels:
- "traefik.enable=true"
- "traefik.http.routers.gitea-web.entrypoints=web"
- "traefik.http.routers.gitea-web.rule=Host(`gitea.docker.localdev`)"
- "traefik.http.routers.gitea-web.service=gitea-web-svc"
- "traefik.http.services.gitea-web-svc.loadbalancer.server.port=3000"
- traefik.http.routers.gitea-http.middlewares=gitea-https
- traefik.http.middlewares.gitea-https.redirectscheme.scheme=https
- traefik.http.routers.gitea-https.entrypoints=websecure
- traefik.http.routers.gitea-https.rule=Host(`gitea.docker.localdev`)
- traefik.http.routers.gitea-https.tls=true
- "traefik.tcp.routers.gitea-ssh.rule=HostSNI(`*`)"
- "traefik.tcp.routers.gitea-ssh.entrypoints=ssh"
- "traefik.tcp.routers.gitea-ssh.service=gitea-ssh-svc"
- "traefik.tcp.services.gitea-ssh-svc.loadbalancer.server.port=22"
networks:
- web
dns:
- 8.8.8.8
- 000.000.0.000 # change it to local LAN adress
- 1.1.1.1
- gitea
extra_hosts:
- "gitea.docker.localdev:000.000.0.000" # change it to local LAN adress
- "droneio.docker.localdev:000.000.0.000" # change it to local LAN adress
droneio:
image: drone/drone:latest
container_name: droneio
restart: unless-stopped
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- ${DOCKER_DATA_DIR}/droneio-data:/data
environment:
- DRONE_SERVER_HOST=droneio.docker.localdev
- DRONE_SERVER_PROTO=https
- DRONE_RPC_SECRET=4810ef8120663ffa960dfa1d78c5d437
# Gitea Config
- DRONE_GITEA_SERVER=https://gitea.docker.localdev/
- DRONE_GITEA_CLIENT_ID=${DRONE_GITEA_CLIENT_ID}
- DRONE_GITEA_CLIENT_SECRET=${DRONE_GITEA_CLIENT_SECRET}
- DRONE_GITEA_SKIP_VERIFY=true
- DRONE_LOGS_PRETTY=true
- DRONE_LOGS_COLOR=true
- DRONE_DEBUG=true
- DRONE_OPEN=true
- DRONE_TRACE=true
- DRONE_NETWORK=default
depends_on:
- gitea
labels:
- traefik.enable=true
- traefik.http.routers.droneio-http.entrypoints=web
- traefik.http.routers.droneio-http.rule=Host(`droneio.docker.localdev`)
- traefik.http.routers.droneio-http.middlewares=droneio-https
- traefik.http.middlewares.droneio-https.redirectscheme.scheme=https
- traefik.http.routers.droneio-https.entrypoints=websecure
- traefik.http.routers.droneio-https.rule=Host(`droneio.docker.localdev`)
- traefik.http.routers.droneio-https.tls=true
networks:
- web
dns:
- 8.8.8.8
- 000.000.0.000 # change it to local LAN adress
- 1.1.1.1
- gitea
drone-runner:
image: drone/drone-runner-docker:latest
container_name: drone-runner
restart: unless-stopped
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
- /var/run/docker.sock:/var/run/docker.sock
ports:
- "3556:3000"
labels:
- traefik.enable=true
- traefik.http.routers.dronerunner-http.entrypoints=web
- traefik.http.routers.dronerunner-http.rule=Host(`dronerunner.docker.localdev`)
- traefik.http.routers.dronerunner-http.middlewares=dronerunner-https
- traefik.http.middlewares.dronerunner-https.redirectscheme.scheme=https
- traefik.http.routers.dronerunner-https.entrypoints=websecure
- traefik.http.routers.dronerunner-https.rule=Host(`dronerunner.docker.localdev`)
- traefik.http.routers.dronerunner-https.tls=true
depends_on:
- droneio
# - gitea
networks:
- web
dns:
- 8.8.8.8
- 000.000.0.000 # change it to local LAN adress
- 1.1.1.1
- gitea
environment:
- DRONE_RPC_PROTO=https
- DRONE_RPC_HOST=droneio.docker.localdev
- DRONE_RPC_SECRET=4810ef8120663ffa960dfa1d78c5d437 # PRC SECRET random string generated by openssl rand -hex 16
- DRONE_RUNNER_CAPACITY=2
- DRONE_RPC_SKIP_VERIFY=true
- DRONE_DEBUG=true
- DRONE_RUNNER_NAME=drone-runner-docker
- DRONE_RUNNER_NETWORKS=web,proxy
networks:
proxy:
external: true
web:
external: true
and also these aliases should be added to traefik's docker-compose.yaml
services:
traefik:
...
...
networks:
# Define the network on which traefik is going to operate.
proxy:
aliases:
- gitea.docker.localdev
- droneio.docker.localdev
web:
I am trying to get a certificate for my docker container but I keep getting errors, below is my docker-compose. This used to work before until i deleted the container to restart it again. I am using Traefik as the proxy and I am using it to request for certificates.
and I keep getting this error when i start my container to get the certitifcates.
Unable to obtain ACME certificate for domains "mydomain.com": unable to generate a certificate for the domains [mydomain.com]: error: one or more domains had a problem:\n[mydomain.com] acme: error: 403 :: urn:ietf:params:acme:error:unauthorized ::
Cannot negotiate ALPN protocol "acme-tls/1" for tls-alpn-01 challenge\n",
"providerName": "myresolver.acme"
Please note i have replaced the actual domain with mydomain.com and other lines of images in the docker compose have been left out for brevity. Is there any rule i am not following properly?
services:
##Reverse Proxy
traefik:
image: library/traefik:v2.6.0
container_name: traefik
labels:
- traefik.enable=false
command:
- --api.insecure=false
- --providers.docker
#
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entryPoint.to=websecure
- --entrypoints.web.http.redirections.entryPoint.scheme=https
- --entrypoints.websecure.address=:443
- --entryPoints.websecure.forwardedHeaders.insecure
- --entryPoints.web.forwardedHeaders.insecure
#
# ...
- --certificatesresolvers.myresolver.acme.email=email#email.com
- --certificatesresolvers.myresolver.acme.tlschallenge=true
- --certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory
# used during the challenge
- --certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
#logs
# Writing Logs to a File
- --log.level=DEBUG
- --log.filePath=/logs/traefik.log
- --log.format=json
## Access Logs
- --accesslog=true
networks:
- traefik
ports:
- "80:80"
- "443:443"
- "8080:8080"
restart: always
volumes:
- ./logs/traefik/:/logs/
- ./letsencrypt:/letsencrypt
- /var/run/docker.sock:/var/run/docker.sock:ro
portainer:
image: portainer/portainer:latest
container_name: portainer
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- traefik
ports:
- "9000:9000"
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./portainer-data:/data
labels:
- "traefik.http.routers.portainer.priority=1"
- "traefik.http.routers.portainer.rule=Host(`mydomain.com`)"
- "traefik.http.routers.portainer.tls=true"
- "traefik.http.routers.portainer.tls.certresolver=myresolver"
networks:
traefik:
name: traefik```
Hi everyone I am trying to enable SSL in my docker-compose.yml file for my backend service. All of my Traefik configuration is done in my docker-compose.yml file, so I may be missing a line. Running docker-compose on this configuration works without SSL and the site is displayed properly, but it does not work when using https. I have checked the Traefik documentation for the certResolvers and I am not sure what I am missing thanks.
version: "3"
networks:
NanoWall-Net:
services:
api:
build:
context: .
dockerfile: Dockerfile
labels:
- "traefik.docker.network=NanoWall-Net"
- "traefik.enable=true"
- "traefik.port=5000"
- "traefik.http.routers.http-catchall.rule=Host(`nanowalldocs.com`)"
- "traefik.http.routers.http-catchall.tls=true"
- "traefik.http.routers.http-catchall.tls.certresolver=le"
- "traefik.http.routers.http-catchall.tls.domains[0].sans=nanowalldocs.com"
- "traefik.http.routers.http-catchall.entrypoints=web"
ports:
- "5000:5000"
networks:
- NanoWall-Net
reverse-proxy:
image: traefik:v2.0
# Enables the web UI and tells Traefik to listen to docker
command:
- "--entryPoints.web.address=:80"
- "--entryPoints.websecure.address=:443"
- "--entryPoints.websecure.http.tls.certResolver: le"
- "--entrypoints.web.http.redirections.entryPoint.scheme=https"
- "--entrypoints.web.http.redirections.entryPoint.to=websecure"
- "--api.insecure=true"
- "--api.debug=true"
- "--api=true"
- "--api.dashboard=true"
- "--providers.docker=true"
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.docker.exposedbydefault=false"
- "--accesslog=true"
- "--accesslog.filepath=/var/log/traefik-access.log"
- "--accesslog.bufferingsize=1000"
- "--log.filePath=/var/log/traefik.log"
- "--certificatesResolvers.le.acme.email=jamar.phillip99#gmail.com"
- "--certificatesResolvers.le.acme.storage=acme.json"
- "--certificatesResolvers.le.acme.httpChallenge=true"
- "--certificatesResolvers.le.acme.httpChallenge.entryPoint=web"
ports:
# The HTTP port
- "80:80"
- "443:443"
# The Web UI (enabled by --api.insecure=true)
- "8080:8080"
networks:
- NanoWall-Net
volumes:
- /acme.json/etc/traefik/acme.json
# So that Traefik can listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock:ro
restart: always
It may not be the only issue, but you are missing a colon in your traefik volumes section. You have:
- /acme.json/etc/traefik/acme.json
I think it should be (assuming your host location is really /acme.json and not ./acme.json or in some other directory):
- /acme.json:/etc/traefik/acme.json
That said, I have also been having an issue where traefik always wants it in /acme.json, so I just put it there instead of in /etc/traefik/acme.json .