I want to configure X-Forwarded-For and X-Forwarded-Proto similar to this post such that I could run my uvicorn server with --proxy-headers
. I checked the relevant documentation and configure my target server's container like the following (the last two labels are of interest):
docker create --name brickserver-playground-deployment \
--rm \
-it \
-e LOG_LEVEL="debug" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $PWD:/app \
-e ENABLE_SSL=false \
--entrypoint /app/docker/start-reload.sh \
--privileged=true \
--label "traefik.http.routers.bs-backend.rule=Host(\"myserver\") && ( PathPrefix(\"/docs\") || PathPrefix(\"/dummy-frontend\") || PathPrefix(\"/auth\") || PathPrefix(\"/brickapi\") )" \
--label traefik.http.routers.bs-backend.entrypoints=websecure \
--label traefik.http.routers.bs-backend.tls=true \
--label traefik.http.routers.bs-backend.tls.certresolver=leresolver \
--label "traefik.docker.network=deployment_default" \
--label "traefik.http.routers.bs-backend.middlewares=testHeader" \
--label "traefik.http.middlewares.testHeader.headers.customrequestheaders.X-Forwarded-Proto=https" \
xxx/container:0.1
I checked the config through traefik api and confirm the everything are configured as is. But it seems like it's not working even with such a simplest setting.
I'm wondering:
- What's wrong with above configuration? Why it doesn't work?
- How to configure the header value dynamically (just like in the above nginx tutorial) according to the user's request rather than hardcoding as what I'm doing in the sample.