【发布时间】:2016-03-18 14:05:15
【问题描述】:
我在我的 Django 应用程序中使用 nginx 作为带有 gunicorn 的反向代理,并且是网络服务器配置的新手。我的应用有一个 postgres 后端,托管它的机器安装了 Ubuntu 14.04 lts。
我有理由怀疑我的 nginx 配置没有正确地将代理集标头转发到 Django 应用程序。有没有办法可以在 linux 命令行上查看(例如打印?)主机、http_user_agent、remote_addr 等转发来测试我的直觉?
其次,如何检查我的 Django 应用是否收到了正确的转发 IP?例如。我可以以某种方式print吗?
/etc/nginx/sites-available/myproject:
server {
listen 80;
server_name example.cloudapp.net;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/mhb11/folder/myproject;
}
location / {
proxy_set_header Host $host;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/home/mhb11/folder/myproject/myproject.sock;
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /home/mhb11/folder/myproject/templates/;
}
}
【问题讨论】:
标签: python django ubuntu nginx proxy