Hi,
I am not an expert on Traefik and I am still learning.
My goal is to host multiple domain/laravel app using Traefik as the proxy. I am struggling with HTTP and HTTPS mixed issues.
My goal is all traffic should flow as HTTPS traffic. Otherwise, I am getting mixed traffic errors. Anyone can point me in the right direction please.
Here is my docker-compose file.
version: '3'
services:
traefik:
container_name: traefik
image: traefik:latest
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- proxy
- backend
ports:
- 80:80
- 443:443
environment:
- CF_API_EMAIL=TTTTTT@TTTTT.com
- CF_DNS_API_TOKEN="ghfhfhgfhfhfhfh"
- CF_ZONE_API_TOKEN="dfgdgfdgdffgfdhfghfgh"
command:
- '--providers.docker=true'
- '--entryPoints.web.address=:80'
- '--entryPoints.metrics.address=:8082'
- '--providers.providersThrottleDuration=2s'
- '--providers.docker.watch=true'
- '--providers.docker.exposedbydefault=false'
- '--accessLog.bufferingSize=0'
- '--api=true'
- '--api.dashboard=true'
- '--api.insecure=true'
- '--ping.entryPoint=web'
- '--metrics.prometheus=true'
- '--metrics.prometheus.addEntryPointsLabels=true'
- '--metrics.prometheus.addServicesLabels=true'
- '--metrics.prometheus.manualrouting=true'
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/traefik.yml:/traefik.yml:ro
- ./data/acme.json:/acme.json
labels:
- log.level=DEBUG
- traefik.enable=true
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`webdash.dwishaventures.com`)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=admin:$$apr1dfgdg423464567hxadfdzni6KcayaerY/"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`webdash.dwishaventures.com`)"
- "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=letsEncrypt"
- "traefik.http.routers.traefik-secure.service=api@internal"
starapp:
image: webdevops/php-nginx:7.4-alpine
container_name: starapp
depends_on:
- mysql
restart: always
environment:
- PHP_DISPLAY_ERRORS=1
- PHP_MEMORY_LIMIT=2048M
- PHP_MAX_EXECUTION_TIME=300
- PHP_POST_MAX_SIZE=500M
- PHP_UPLOAD_MAX_FILESIZE=256M
volumes:
- ./starhardware.com.my/app/:/app
expose:
- 80
- 443
labels:
- traefik.enable=true
- traefik.http.routers.starapp.entrypoints=http
- traefik.http.routers.starapp.rule=Host(`app.starhardware.com.my`)
- traefik.http.middlewares.starapp-https-redirect.redirectscheme.scheme=https
- traefik.http.routers.starapp.middlewares=starapp-https-redirect
- traefik.http.routers.starapp-secure.entrypoints=https
- traefik.http.routers.starapp-secure.rule=Host(`app.starhardware.com.my`)
- traefik.http.routers.starapp-secure.tls=true
- traefik.http.routers.starapp-secure.tls.certresolver=letsEncrypt
- traefik.http.routers.starapp-secure.service=starapp
- traefik.http.services.starapp.loadbalancer.server.port=80
networks:
- proxy
- backend
Next is my traefik.yml file
api:
dashboard: true
entryPoints:
http:
address: ":80"
https:
address: ":443"
accessLog:
filePath: "/opt/containers/traefik/data/access.log"
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
certificatesResolvers:
letsEncrypt:
acme:
email: TTTTTTT@gmail.com
storage: acme.json
#caServer: https://acme-staging-v02.api.letsencrypt.org/directory
dnsChallenge:
provider: cloudflare
delayBeforeCheck: 300
When I am trying to install WordPress on
https://app.starhardware.com.my/wp-admin/setup-config.php
Traffic is mixed of HTTP and HTTPS.
I want both request and response traffic should use HTTPS Any clue will be really helpful.
Thank you.
Dwija