Hi @cakiwi , I have the exactly same configuration. It is not working. That's why I shared full configuration. There should be something wrong but I couldn't find / fix it.
I hope you may help me to solve this.
Maybe @zespri can help me to solve this. I created a new topic as we talked on the other topic.
I wish I could. I couldn't understand the tutorials. That's why I stuck and not able to solve this issue. I asked the community. I hope someone can help me.
Sure. What particular problem / issue are you having that preventing you from doing the suggested update? What in particular in traefik documentation you do not understand? I hope I can explain that, you just need to tell me where the problem is.
Hi @zespri . I have basic knowledge about Server, Traefik, Networking etc. Documentation is not suitable for my level. I am not able to change configuration by reading the documentation. I am just using the simple configuration and want to redirect http and www to https://blueway.app for canonical SEO problem.
I changed configuration from the previous post that I already mentioned you. But, I couldn't solve it. That's why I am asking for help from you. If I was able to achieve the goal then I won't ask people and take their time.
I am writing here, because I need help. I spend so much time and couldn't do it.
I can help you, if I know what is the particular problem you need help with. The problem that I see with your configuration I identified in my post earlier in this thread in the same post, I explained what need to be changes to fix this problem. Once you've done that and posted your results, we can proceed onto the next issue until we get this resolved.
It appears that you have problems with doing the change requested but it is not unclear what that problem is.
You wrote:
Documentation is not suitable for my level. I am not able to change configuration by reading the documentation.
I would like to know what particular problem do you have that is in the way. From my own experience if I cannot change configuration by reading documentation, this is most likely because I do not understand the documentation. In this case I usually can identify what is that, that I have trouble getting my head around, and what does not make sense.
If we could find out that, we could get that answered and move further.
Mutually exclusive means that it should use either one or the other, you cannot use both. Since you have more in the config file as compared to the command line, I suggest that you fix this by moving the command line parameters to the config. The format is of course different, so the reference could be helpful:
I know exactly how you feel. Regardless of how hard I try I just can't wrap my head around this stuff, so the documentation is useless to me. Basically I just copy and paste code pieces from examples and problems and then after weeks of messing around something will just work... and I will have no idea why .
I must have stumbled on this and used it weeks ago trying to get global redirection working properly because this is what my code looks like. I thought it was working great as my existing websites are redirecting as expected though there is a pretty big catch that I can't figure out. Spent the last week trying to get Wordpress working on HTTPS with no success to finally realise that the LE Certificate isn't being created, so weeks looking in the complete wrong spot .
What I have found is that while global redirection now works great, any 'new' services (including whoami) are not having certificates created and I can't for the life of me figure out why.
Here's my code and I'm hoping like hell someone can help my figure out how I broke the certificates:
version: "3.8"
volumes:
letsencrypt:
logs:
networks:
traefik-public:
external: true
services:
traefik:
image: traefik:2.4.12
networks:
- traefik-public
command:
# Enable Docker swarm; Enable Docker in Traefik
- --providers.docker.swarmMode=true
- --providers.docker.exposedbydefault=false
- --providers.docker.network=traefik-public
# Entrypoints and Global http->https redirection
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entrypoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.websecure.address=:443
# Global TLS (Let's Encrypt)
- --entrypoints.websecure.http.tls=true
# Let's Encrypt SSL
- --certificatesresolvers.leresolver.acme.email=my@email.com
- --certificatesresolvers.leresolver.acme.storage=/letsencrypt/acme.json
- --certificatesresolvers.leresolver.acme.tlschallenge=true
# Enable dashboard
- --api.dashboard=true
# Logging (Level: DEBUG, ERROR, INFO)
- --log.level=DEBUG
- --log.filePath=/logs/traefik.log
- --log.format=json
ports:
- "80:80"
- "443:443"
volumes:
- letsencrypt:/letsencrypt
- logs:/logs
# Let Traefik listen to the Docker events
- /var/run/docker.sock:/var/run/docker.sock:ro
deploy:
placement:
constraints:
- node.role == manager
labels:
traefik.enable: "true" # Required if containers not exposed by default
# Global redirection: https://www -> https://
traefik.http.routers.wwwsecure-catchall.rule: hostregexp(`{host:(www\.).+}`)
traefik.http.routers.wwwsecure-catchall.entrypoints: websecure
traefik.http.routers.wwwsecure-catchall.tls: "true"
traefik.http.routers.wwwsecure-catchall.middlewares: wwwtohttps
## Redirection middleware: https://www -> https:// (http->https redirection at entrypoint level)
traefik.http.middlewares.wwwtohttps.redirectregex.regex: ^https?://(?:www\.)?(.+)
traefik.http.middlewares.wwwtohttps.redirectregex.replacement: https://$${1}
traefik.http.middlewares.wwwtohttps.redirectregex.permanent: "true"
# UI Dashboard
traefik.http.routers.traefik.rule: "Host(`traefik.mywebsite.com`)"
traefik.http.routers.traefik.service: api@internal
traefik.http.routers.traefik.middlewares: auth-traefik
traefik.http.services.traefik.loadbalancer.server.port: 8080 # Port used by service (Docker Swarm requirement, defined in image)
## Basic Auth
traefik.http.middlewares.auth-traefik.basicauth.users: "user:SomeRandomStringHashThing"
whoami:
image: containous/whoami:v1.3.0
networks:
- traefik-public
deploy:
labels:
traefik.enable: "true" # Required if containers not exposed by default
# Host & Entrypoint
traefik.http.routers.whoami.rule: "Host(`traefik-whoami.mywebsite.com
traefik.http.routers.whoami.middlewares: auth-whoami
traefik.http.services.whoami.loadbalancer.server.port: 80 # Port used by service (Docker Swarm requirement, defined in image)
## Basic Auth Middleware
traefik.http.middlewares.auth-whoami.basicauth.users: "user:SomeOtherRandomStringHashThing"
Ignore the last post, I figured it out for myself. Turns out that in the process of changing to using global code, I had removed the following line: traefik.http.routers.abk-whoami-2.tls.certresolver: leresolver
When trying to fix this issue the other day I had been putting http as the resolver not leresolver, that will teach me to dig back through Git for my old code rather than copying and pasting someone else's .
Hi @mindgonemad Can you please share your www to non www config? I'm confused about this line. traefik.http.routers.abk-whoami-2.tls.certresolver: leresolver
It was from a seperate docker stack that had it's own "who am I". What I should have written was: traefik.http.routers.whoami.tls.certresolver: leresolver
WARNING: I thought I had this working but I'm running into issues as I tried getting Wordpress running using it and neither the https or www redirects are working yet the "who am I"'s seemed work last I checked. Honestly not sure what's going on or how to resolve it and haven't been able to spend much time due to health issues.