Created
February 25, 2012 21:48
-
-
Save kuleszaj/1911022 to your computer and use it in GitHub Desktop.
Simple nginx reverse proxy with extra headers.
This file contains hidden or 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
server { | |
listen 1.2.3.4:80; | |
server_name railsapp.example.com; | |
location / { | |
proxy_set_header Host $host; | |
# So the original HTTP Host header is preserved | |
proxy_set_header X-Real-IP $remote_addr; | |
# The IP address of the client (which might be a proxy itself) | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
# The IP address in the HTTP X-Forwarded-For header (which would be the 'origin' client). | |
proxy_pass http://rails_application; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you please provide a working example of this active on a remote location? I want to fetch the remote address on my application through javascript. The application is deployed on the remote host here, and that remote host is proxied by a reverse proxy server (setup through nginx).