Skip to content
Myr

Add simple proxying nginx config to docs.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Origin: https://gist.github.com/2269917

authored by Ron DuPlain · committed by Ron DuPlain · parent 976c957 · Browse files · 1 file+28 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Origin:
  • https: //gist.github.com/2269917

Diff stats

1 file+28 added−6 removed

  • other:+28 added−6 removed

1 file+28 added−6 removed

modified:docs/deploying/wsgi-standalone.rst+28 added-6 removed
69 unmodified lines
7071Proxy Setups72------------7374If you deploy your application using one of these servers behind an HTTP75proxy you will need to rewrite a few headers in order for the76application to work. The two problematic values in the WSGI environment77usually are `REMOTE_ADDR` and `HTTP_HOST`. Werkzeug ships a fixer that78will solve some common setups, but you might want to write your own WSGI79middleware for specific setups.74If you deploy your application using one of these servers behind an HTTP proxy75you will need to rewrite a few headers in order for the application to work.76The two problematic values in the WSGI environment usually are `REMOTE_ADDR`77and `HTTP_HOST`. You can configure your httpd to pass these headers, or you78can fix them in middleware. Werkzeug ships a fixer that will solve some common79setups, but you might want to write your own WSGI middleware for specific80setups.8182Here's a simple nginx configuration which proxies to an application served on83localhost at port 8000, setting appropriate headers::8485 server {86 listen 80;8788 server_name _;8990 access_log /var/log/nginx/access.log;91 error_log /var/log/nginx/error.log;9293 location / {94 proxy_pass http://127.0.0.1:8000/;95 proxy_redirect off;9697 proxy_set_header Host $host;98 proxy_set_header X-Real-IP $remote_addr;99 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;100 }101 }102103The most common setup invokes the host being set from `X-Forwarded-Host`104and the remote address from `X-Forwarded-For`::105106 from werkzeug.contrib.fixers import ProxyFix
21 unmodified lines