1 from werkzeug.contrib.fixers import ProxyFix
2
3 ....
4 app.wsgi_app = ProxyFix(app.wsgi_app)
5 ...
1 server {
2 listen 80;
3
4 server_name _;
5
6 access_log /var/log/nginx/access.log;
7 error_log /var/log/nginx/error.log;
8
9 location / {
10 proxy_pass http://127.0.0.1:8000/;
11 proxy_redirect off;
12
13 proxy_set_header Host $host;
14 proxy_set_header X-Real-IP $remote_addr;
15 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
16 proxy_set_header X-Forwarded-Proto $scheme;
17 }
18 }
1 from flask import request
2 print request.remote_addr

Comments (0)