| 1 |
### Nginx Users |
| 2 |
|
| 3 |
By default,using Ningx as a reverse proxy to Gunicorn doesn't forward the client's IP to gunicorn. |
| 4 |
As a reverse proxy, NGINX will receive HTTP requests from clients and then send those requests to our |
| 5 |
Gunicorn WSGI server. The problem is that NGINX hides information from our WSGI server. |
| 6 |
The HTTP request that Gunicorn receives is not the same as the one that NGINX received from the client. |
| 7 |
To solve this problem, open up your `nginx conf file` and add the following lines to the `location` block |
| 8 |
``` |
| 9 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 10 |
proxy_set_header Host $host; |
| 11 |
proxy_set_header X-Forwarded-Proto $scheme; |
| 12 |
``` |
| 13 |
|
| 14 |
``` |
| 15 |
server { |
| 16 |
listen 80; |
| 17 |
location / { |
| 18 |
include proxy_params; |
| 19 |
proxy_pass http://unix:/<where_your_sock_file_is>/coincard.sock; |
| 20 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 21 |
proxy_set_header Host $host; |
| 22 |
proxy_set_header X-Forwarded-Proto $scheme; |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
``` |