We have setup traefik proxy docker container and wordpress docker container in our server. And we have a domain, if we call this domain then it wil redirect to traefik container port 80 and it will redirect it to wordpress site. Till here it is completed task. The project is for authentication purpose, whenever the wordpress site is loading then it should redirect to forwardauth middleware and then it should forward to keycloak container and ask user and password and fetch it form db and authenticate use the wordpress site.
Share your full Traefik static and dynamic config, and docker-compose.yml if used.
Format your code with 3 backticks in front and after, or select the code and press </> . In yaml every space matters. And it makes it so much more readable for people trying to help you.
@bluepuma77 Thank you for the reply.
shared above code with correct intentations, we are accessing http://domain.com and we are getting wordpress page using above code.
we need to access through https://domain.com but it is not working while setting entrypoint https and port 443.
please mention what changes should be done in this code to access traefik through https://domain.com.
And also kindly mention how to configure forward auth middleware for forwarding this to keycloak authentication.
For ForwardAuth read the according Traefik ForwardAuth doc. To set Traefik up with keycloak, just check one of the many tutorials on the Internet (example 1, 2, 3).
"80:80"
- "443:443" # Map the HTTPS port
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./letsencrypt:/letsencrypt # Mount a directory for Let's Encrypt data
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(roshan.live) && PathPrefix(/db)"
- "traefik.http.routers.traefik.entrypoints=http,https" # Allow both HTTP and HTTPS
- "traefik.http.routers.traefik.tls.certresolver=myresolver" # Use the certificate resolver
- "traefik.port=8080"
networks:
- traefik_network
wordpress:
image: wordpress
restart: always
environment:
WORDPRESS_DB_HOST: mysql
WORDPRESS_DB_USER: wpuser
WORDPRESS_DB_PASSWORD: wppassword
WORDPRESS_DB_NAME: wpdb
labels:
- "traefik.enable=true"
- "traefik.http.routers.wordpress.rule=Host(roshan.live)"
- "traefik.http.routers.wordpress.entrypoints=http,https" # Allow both HTTP and HTTPS
- "traefik.http.routers.wordpress.tls.certresolver=myresolver" # Use the certificate resolver
- "traefik.port=80"
networks:
- traefik_network
volumes:
- wp-data:/var/www/html
@bluepuma77 above code is working i am not able to correct intentation, i am attaching github link it has
docker compose to load wordpress in https, and keycloak container setting command also.
i need to configure forwardauth middleware for getting authentication in wordpress page using keycloak. i have configured forwardauth by referring these above documents you shared, but it is not working. also attached that file also. please refer and help.
Format your code with 3 backticks in front and after, or select the code and press </> . In yaml every space matters. And it makes it so much more readable for people trying to help you.
But note that you can't do any role management with this, as WordPress would need to support getting the user/role data via headers. So you can only grant access to WordPress or not at all.
For more guidance just check any tutorial on Traefik/Keycloak: 1, 2, 3