I'm trying to set up docker to utilize a reverse proxy on my homelab and after configuring and running docker compose up -d
I find a 301 moved permanently error on port 80 and a 404 error on port 443. I am trying to use this guide to utilize ssl certificates and eventually open some of my services up to be used by friends and family. Navigating to the ubuntu server hosting docker at 10.3.14.101 on ports 80 and 443 both yield the 404 error. Running nmap to see if the ports are just unreachable yields that port 80 is being redirected to port 443.
Curl on my main machine:
ptolemy@Phobos:~$ curl 10.3.14.101:443 -i
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Sat, 03 Feb 2024 11:01:18 GMT
Content-Length: 19
404 page not found
Curl on docker host machine:
ptolemy@titan:~$ curl 10.3.14.101:443 -i
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Sat, 03 Feb 2024 11:02:14 GMT
Content-Length: 19
404 page not found
I have followed the guide almost to a T and even went as far as retrieving the configuration files from this github page and changing the values to my personal information and following my file hierarchy of:
/home/ptolemy/docker/traefik/acme.json
/home/ptolemy/docker/traefik/config.yml
/home/ptolemy/docker/traefik/traefik.yml
/home/ptolemy/docker-compose/traefik/docker-compose.yml
docker-compose.yml:
ptolemy@titan:~/docker-compose/traefik$ cat docker-compose.yml
version: '3'
services:
traefik:
image: traefik:latest
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
ports:
- 80:80
- 443:443
environment:
- CF_DNS_API_TOKEN=<MYAPITOKEN>
# If you choose to use an API Key instead of a Token, specify your email as well
# - CF_API_EMAIL=user@example.com
# - CF_API_KEY=YOUR_API_KEY
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /home/ptolemy/docker/traefik/traefik.yml:/traefik.yml:ro
- /home/ptolemy/docker/traefik/acme.json:/acme.json
- /home/ptolemy/docker/traefik/config.yml:/config.yml:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.tls=true"
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`traefik-dashboard.<MYDOMAIN>`)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=<DASHBOARDLOGINHASH>"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`traefik-dashboard.<MYDOMAIN>`)"
- "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=cloudflare"
- "traefik.http.routers.traefik-secure.tls.domains[0].main=<MYDOMAIN>"
- "traefik.http.routers.traefik-secure.tls.domains[0].sans=*.<MYDOMAIN>"
- "traefik.http.routers.traefik-secure.service=api@internal"
networks:
proxy:
external: true
traefik.yml:
api:
dashboard: true
debug: true
entryPoints:
http:
address: ":80"
http:
redirections:
entryPoint:
to: https
scheme: https
https:
address: ":443"
serversTransport:
insecureSkipVerify: true
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
filename: /config.yml
certificatesResolvers:
cloudflare:
acme:
email: <MYEMAIL>
storage: acme.json
dnsChallenge:
provider: cloudflare
#disablePropagationCheck: true # uncomment this if you have issues pulling certificates through cloudflare, By setting this flag to true disables the need to wait for the propagation of the TXT record to all authoritative name servers.
resolvers:
- "1.1.1.1:53"
- "1.0.0.1:53"
config.yml: (empty as I currently don't have any other services to route to)
ptolemy@titan:~/docker/traefik$ cat config.yml
ptolemy@titan:~/docker/traefik$
acme.json:
I'm hesitant to paste here but it does have data in it:
-rw------- 1 ptolemy ptolemy 16K Feb 3 10:28 acme.json
traefik logs:
ptolemy@titan:~/docker/traefik$ sudo docker logs traefik
[sudo] password for ptolemy:
time="2024-02-03T10:33:40Z" level=info msg="Configuration loaded from file: /traefik.yml"
Let me know if you need any more information. Frankly, I'm tired at this point and genuinely thought this would be an easy set up on my test lab before implementing on my albeit barebones main lab.