Hi All,
I've been reading the tutorials and topics on this forum, but after being at this for 2 days I haven't been able to accomplish the relatively simple task of making a subdomain proxy for a port. What I intend to do is to run a few node.js apps and a few containers on my server (a vps on Digitalocean), and have Traefik proxy them with subdomains. I'm currently testing out a subdomain proxy with a portainer instance that I have installed before Traefik. This is my current docker-compose.yml for Traefik:
version: '3.8'
services:
reverse-proxy:
image: traefik:v2.10
command:
- --providers.docker
- --api.insecure=false
- --api.dashboard=true
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --certificatesresolvers.letsencrypt.acme.tlschallenge=true
- --certificatesresolvers.letsencrypt.acme.email=<my email here>
- --certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- letsencrypt:/letsencrypt
labels:
- "traefik.http.routers.test1.rule=Host(`test1.mydomain.com`)"
- "traefik.http.routers.test1.middlewares=redirect-to-google"
- "traefik.http.middlewares.redirect-to-google.redirectregex.regex=^http://test1\\.mydomain\\.com/(.*)"
- "traefik.http.middlewares.redirect-to-google.redirectregex.replacement=https://google.com/$${1}"
- "traefik.http.routers.portainer.rule=Host(`portainer.mydomain.com`)"
- "traefik.http.routers.portainer.entrypoints=websecure"
- "traefik.http.routers.portainer.service=portainer"
- "traefik.http.services.portainer.loadbalancer.server.port=9443"
- "traefik.http.services.portainer.loadbalancer.server.scheme=http"
- "traefik.http.routers.mydomain.rule=Host(`mydomain.com`)"
- "traefik.http.routers.mydomain.middlewares=redirect-to-netlify"
- "traefik.http.middlewares.redirect-to-netlify.redirectregex.regex=^http://mydomain\\.com/(.*)"
- "traefik.http.middlewares.redirect-to-netlify.redirectregex.replacement=https://mynetlifyapp.netlify.app/$${1}"
- "traefik.http.routers.mydomain-secure.rule=Host(`mydomain.com`)"
- "traefik.http.routers.mydomain-secure.entrypoints=websecure"
- "traefik.http.routers.mydomain-secure.middlewares=redirect-to-netlify-secure"
- "traefik.http.middlewares.redirect-to-netlify-secure.redirectscheme.scheme=https"
- "traefik.enable=true"
whoami:
# A container that exposes an API to show its IP address
image: traefik/whoami
labels:
- "traefik.http.routers.whoami.rule=Host(`whoami.mydomain.com`)"
- "traefik.http.routers.whoami.entrypoints=websecure"
- "traefik.http.routers.whoami.tls=true"
- "traefik.http.routers.whoami.tls.certresolver=letsencrypt"
- "traefik.http.routers.whoami.middlewares=whoami-redirect-secure"
- "traefik.http.middlewares.whoami-redirect-secure.redirectscheme.scheme=https"
networks:
traefik-proxy_default:
external: true
volumes:
letsencrypt:
external: false
From the above:
test1.mydomain.com
successfully redirects tohttps://google.com/
mydomain.com
successfully redirects tohttps://mynetlifyapp.netlify.app/
whoami.mydomain.com
successfully displays the server information, and http requests are redirected to https.portainer.mydomain.com
however, returns a 404, no matter if i access it via http or https. (edit) But Portainer works well independently at https://myipaddress:9443, no matter if I have Traefik set up or not.
I've read a few topics on this forum and it seems like the configuration should work. Can anyone guide me as to what I'm missing out on? I'm trying not to setup another container service in this docker-compose file and proxy them from there as some of my node.js apps are not containerized.