-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Needed to change how we preserve the hosts; must preserve port number #17
Open
ntl
wants to merge
8
commits into
jaswope:master
Choose a base branch
from
ntl:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@jaswope - ping. Just curious if you have a 👍 or 👎 to spare. |
eric1234
added a commit
to eric1234/rack-legacy
that referenced
this pull request
Jan 20, 2014
The preserve_host option on rack-rewrite seems a bit off. I would assume it would mean it keeps the hostname requested. But instead it replaces it with the internal hostname (the host we proxy to). There is a ticket related to this (jaswope/rack-reverse-proxy#11). In addition, even if it pulled from the right host it also doesn't include the port. There is also already a ticket for this (jaswope/rack-reverse-proxy#17). To resolve this I simply avoiding using the preserve host option. This allows the original host to pass on through to PHP (it doesn't seem to need to be explicitly set, PHP already know it). Both of these option (wrong host and missing port) cause some PHP scripts, like Wordpress, who are trying to redirect to a canonical URL to get caught in an infinate loop. I am also now stripping out the index.php from the PATH_INFO before proxying off. The PHP webserver has it's own built-in method of looking for the index.php. So we add it for detecting the PHP handler should be called but then remove it to let PHP do things it's own way. This helps for script like Wordpress that try to direct to a canoncial URL. It prevent it from bouncing between index.php and the root directory. It may be slightly incorrect for cases where the user explicitly chose to pull up the index.php script. But in the real world I don't know where that would cause a problem and making this change solves a real world problem for Wordpress. Finally, I am passing on the HTTP_X_FORWARDED_FOR header. Although not standardized it is fairly widely and provide a way for the script to determine the IP address of the real browser since REMOTE_ADDR will be set to the proxy server.
Forwarded host
Update version and add new method dependency that was missed
* To support responses that have been gzipped by Rack::Deflate
Delete Content-Length from response headers
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First of all, thanks for writing this -- it came in super handy at work today.
I have a rather unusual setup as I am trying to run my reverse proxy on port 9292. I set :preserve_host => true in my options, but :preserve_host only sets the hostname part of the HOST environment variable. I needed hostname:port_number.