Skip to content

Commit 9a1d616

Browse files
committed
Add simple proxying nginx config to docs.
Origin: https://gist.github.com/2269917
1 parent 976c957 commit 9a1d616

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

docs/deploying/wsgi-standalone.rst

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,34 @@ event loop::
7171
Proxy Setups
7272
------------
7373

74-
If you deploy your application using one of these servers behind an HTTP
75-
proxy you will need to rewrite a few headers in order for the
76-
application to work. The two problematic values in the WSGI environment
77-
usually are `REMOTE_ADDR` and `HTTP_HOST`. Werkzeug ships a fixer that
78-
will solve some common setups, but you might want to write your own WSGI
79-
middleware for specific setups.
74+
If you deploy your application using one of these servers behind an HTTP proxy
75+
you will need to rewrite a few headers in order for the application to work.
76+
The two problematic values in the WSGI environment usually are `REMOTE_ADDR`
77+
and `HTTP_HOST`. You can configure your httpd to pass these headers, or you
78+
can fix them in middleware. Werkzeug ships a fixer that will solve some common
79+
setups, but you might want to write your own WSGI middleware for specific
80+
setups.
81+
82+
Here's a simple nginx configuration which proxies to an application served on
83+
localhost at port 8000, setting appropriate headers::
84+
85+
server {
86+
listen 80;
87+
88+
server_name _;
89+
90+
access_log /var/log/nginx/access.log;
91+
error_log /var/log/nginx/error.log;
92+
93+
location / {
94+
proxy_pass http://127.0.0.1:8000/;
95+
proxy_redirect off;
96+
97+
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+
}
80102

81103
The most common setup invokes the host being set from `X-Forwarded-Host`
82104
and the remote address from `X-Forwarded-For`::

0 commit comments

Comments
 (0)