Feat: support for RR in Docker behind proxy in another Docker#131
Feat: support for RR in Docker behind proxy in another Docker#131FluffyDiscord wants to merge 2 commits into
Conversation
|
Did you tried the If the proxy is local, you should add 127.0.0.1. I did it locally and it seems to work as expected: $ curl http://localhost:8080/test -H 'x-forwarded-proto: https'
{"url":"https:\/\/localhost:8080\/home"}
$ curl http://localhost:8080/test
{"url":"http:\/\/localhost:8080\/home"} |
|
I did try, my framework:
trusted_proxies: '127.0.0.1/8,REMOTE_ADDR,SERVER_NAME'
trusted_headers: [ 'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port', 'x-forwarded-prefix' ]That did not work, until I added changes in this PR. Basically, my setup is like this: HTTPS Web > Nginx in Docker > HTTP to RR & Symfony in another Docker |
|
By chance, would you be able to provide a reproducer repo? |
|
Not sure if entirely possible. I bumped into that issue after deploying to production - on real domain. The docker nginx proxy cannot generate/use self signed certificates to simulate it locally. You need to have live domain. If thats okay, I can probably create reproducer with docker-compose, tho you will need to deploy it somewhere yourself. |
|
Yeah I have domains to test it :) |
|
@FluffyDiscord I had the similar problem and the problem was in "trusted_proxies" param For example, on local env I am using "nginx-proxy" docker image and it pass the ip 192.168.0.0/16 Also, we are mapping the x-forwarded-* in nginx config for prod |
If RR is running inside Docker and we simply pass
httpsrequests from proxy (basicaly proxy manages certificates) to the RR instance ashttp, the parsedurischeme in this bundle will always be in this casehttpand Symfony will now use invalid schema or add 443 port when generating URLs.Checking if
X-Forwarded-Protois trusted header and making it priority inHttpFoundationWoker->configureServer()fixes this issue. To make the rest of Symfony proxy features work we also need to setREMOTE_ADDRto theX-Forwarded-Forheader, also only if its trusted.This should be a non breaking change for everyone.