drave
August 21, 2024, 4:57pm
1
Hello everyone
I am new to traefik and am setting up a nodejs application as a frontend.
This is my docker-compose:
services:
my-site:
image: image
ports:
- '8000:80'
labels:
- "traefik.enable=true"
- "traefik.http.routers.my-site.rule=Host(`myurl.com`)"
- "traefik.http.routers.my-site.service=my-site"
- "traefik.http.services.my-site.loadbalancer.server.port=8000"
- "traefik.http.routers.my-site.entrypoints=websecure"
- "traefik.http.routers.my-site.tls.certresolver=myresolver"
- "traefik.http.middlewares.my-site-redirectscheme.redirectscheme.scheme=https"
- "traefik.http.middlewares.my-site-redirectscheme.redirectscheme.permanent=true"
- "traefik.http.routers.my-site.middlewares=my-site-redirectscheme"
traefik:
image: traefik:v3.1
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./letsencrypt:/letsencrypt
- ./traefik.http.yml:/etc/traefik/traefik.yml
I have two problems that I cannot understand.
http does not work and returns me 404 page not found
the redirect from http to https does not work
Can you help me understand where I am going wrong?
Thank you very much
if I'm not mistaken you should add @docker
to your last label to specify the source of the midlewsare you are refering to, otherwise do you see anything log wise?
drave
August 21, 2024, 5:20pm
3
Thank you for fyour reply.
I do not fine nothing in container logs:
2024-08-21T17:17:27Z INF Starting provider aggregator aggregator.ProviderAggregator
2024-08-21T17:17:27Z INF Starting provider *traefik.Provider
2024-08-21T17:17:27Z INF Starting provider *docker.Provider
2024-08-21T17:17:27Z INF Starting provider *acme.ChallengeTLSALPN
2024-08-21T17:17:27Z INF Starting provider *acme.Provider
2024-08-21T17:17:27Z INF Testing certificate renew... acmeCA=https://acme-v02.api.letsencrypt.org/directory providerName=myresolver.acme
2024-08-21T17:17:31Z INF Register... providerName=myresolver.acme
drave
August 21, 2024, 5:22pm
4
Thank you for your reply!
I checked the logs but there is nothing
2024-08-21T17:17:27Z INF Starting provider aggregator aggregator.ProviderAggregator
2024-08-21T17:17:27Z INF Starting provider *traefik.Provider
2024-08-21T17:17:27Z INF Starting provider *docker.Provider
2024-08-21T17:17:27Z INF Starting provider *acme.ChallengeTLSALPN
2024-08-21T17:17:27Z INF Starting provider *acme.Provider
2024-08-21T17:17:27Z INF Testing certificate renew... acmeCA=https://acme-v02.api.letsencrypt.org/directory providerName=myresolver.acme
2024-08-21T17:17:31Z INF Register... providerName=myresolver.acme
This is the traefik container logs.
drave
August 22, 2024, 7:40am
5
I solved everything, this is my new docker-compose:
- "traefik.enable=true"
#routes
- "traefik.http.routers.my-site.rule=Host(`my-site.com`)"
- "traefik.http.routers.my-site.entrypoints=web"
- "traefik.http.routers.my-site.middlewares=test-redirectscheme"
- "traefik.http.routers.my-site-secure.rule=Host(`my-site.com`)"
- "traefik.http.routers.my-site-secure.entrypoints=websecure"
- "traefik.http.routers.my-site-secure.tls.certresolver=myresolver"
- "traefik.http.routers.my-site-secure.middlewares=test-redirectscheme"
# Services
- "traefik.http.services.catapp-secure.loadbalancer.server.port=8000"
# Redirect Scheme HTTP -> HTTPS
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.scheme=https"
- "traefik.http.middlewares.test-redirectscheme.redirectscheme.permanent=true"
system
Closed
August 25, 2024, 7:40am
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.