RequestFactory: fix behavior behind proxy#81
RequestFactory: fix behavior behind proxy#81grongor wants to merge 4 commits intonette:masterfrom grongor:fix-proxy-https
Conversation
grongor
commented
Jan 31, 2016
- bugfix
- issues - https + nginx proxy #4
- documentation - not needed
- BC break - may break some edge-case server proxies, most servers should stay intact
|
👍 |
|
👍 It just took almost 2 years to implement such simple thing. 😭 |
|
Shouldn't we do something with HTTP_X_FORWARDED_PORT as well? |
|
@enumag I was thinking exactly the same thing. How will Nette\Http\Url and/or routers work now when https mode is enabled over port 80? Wouldn't this generate nonsense like https://example.com:80/? |
|
What do you think about that master...grongor:fix-proxy-port ? |
|
Has anyone considered security implication? |
|
I was thinking about security in this way. The attacker can fake the Switch from Any other point of view? |
|
@JanTvrdik @milo Yes, I was thinking about it the same way. If the proxy is able to mess with your headers then you can't trust it anyway - no matter what we put at server side. There might be a problem with misconfiguration of the proxy but we can't really predict that. |
|
How does Symfony and Zend handle this? |
|
@enumag That's what I thought. The current trusted proxy check should be extracted and used for HTTP_X_FORWARDED_PROTO as well. |
|
@JanTvrdik Well it seems that by default the trustedProxies array in symfony is empty. But I'm not sure if there are some added automatically elsewhere. |
|
Symfony configures trusted proxies using kernel parameter: https://github.com/symfony/symfony/blob/83b53f4a89fa2f436ba0f8d88b0714aa534b2cd2/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php#L53 |
|
I added the |
src/Http/RequestFactory.php
Outdated
There was a problem hiding this comment.
I'd put these outside of the foreach.
There was a problem hiding this comment.
Well, I can do that but I will have to copy the $usingTrustedProxy === true condition ... do you think that removing one indention is worth it?
There was a problem hiding this comment.
I just think that any logic that only happens once should be outside of a loop if possible.
Also you can skip the === true part.
There was a problem hiding this comment.
That makes sense, alright :) Yeah I will, I was just trying to be clear for the purpose of comment :)
|
Should I point out all the issues or will @dg rewrite it anyway? |
|
Please point out the issues, otherwise I won't learn what's wrong with this contribution :) |
src/Http/RequestFactory.php
Outdated
There was a problem hiding this comment.
There should be space after (bool), the count call should be removed.
There was a problem hiding this comment.
****, you are right, I again blindly copied the code from @Majkl578 :D
There was a problem hiding this comment.
Sorry, count was a leftover, originally I had it like count(...) !== 0; but then I changed my mind. :)
|
Some more thoughts – I would try to remove the |
|
One of reasons to keep the proxy logic together is #20 |