@@ -71,12 +71,34 @@ event loop::
71
71
Proxy Setups
72
72
------------
73
73
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
+ }
80
102
81
103
The most common setup invokes the host being set from `X-Forwarded-Host `
82
104
and the remote address from `X-Forwarded-For `::
0 commit comments