【发布时间】:2014-04-03 03:13:34
【问题描述】:
我正在使用 CentOS 6.5,主机名 NAFD 仅与 IP 地址 192.9.200.69 一起使用。我使用这个tutorial成功地安装了带有Supervisor的Django-NginX-Gunicorn。
django 在127.0.0.1:8000 中运行成功,没有错误。我在 root 用户或 CentOS 中的其他用户中访问网络服务器 django admin 没有问题。假设 django webserver 应该可以在网络中访问,我现在可以进入下一个阶段,从客户端计算机测试应用程序。
问题从这里开始。
当我尝试使用http://nafd:8000/admin 从网络中的客户端计算机进行连接时,它给了我page not found。但是当我使用http://192.9.200.69/admin 时,我得到了 Nginx Welcome Powered Page。
我已经将 CentOS 防火墙设置为接受来自 80 和 8000 的端口。我可以使用它的 ip 地址 ping 网络服务器。
这是我第一次使用 Nginx-Gunicorn 和 Supervisor。我只在 Win7 中使用 Django,而从客户端访问网络服务器没有问题。
通过阅读其他相关问题和可能的解决方案,我现在的方向是在我的 CentOS 6.5 中安装 DNS 服务器。
如果这是正确的做法,我需要帮助吗?或者有没有其他可能的方法来解决这个问题。
感谢您抽出宝贵时间阅读。
追踪路线结果:
C:\Windows\System32>tracert -4 192.9.200.69
Tracing route to 192.9.200.69 over a maximum of 30 hops
1 1 ms <1 ms <1 ms 192.9.200.69
Trace complete.
NGINX 配置
server {
server_name nafd;
access_log off;
location /static/ {
alias /opt/nafd/nafd_proj/nafd_proj/static;
}
location / {
proxy_pass http://127.0.0.1:80;
proxy_set_header X-Forward-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa OUR NOR ONL UNI COM NAV"';
}
}
Gunicorn 配置
command = '/opt/nafd/bin/gunicorn'
pythonpath = '/opt/nafd/nafd_proj'
bind = '127.0.0.1:80'
workers = 3
#user = 'nafdit'
更新
当我在 python manage.py runserver 0.0.0.0:8001 中运行 django 时,我可以使用 url 中的 192.9.200.69:8001/admin 从网络中的任何计算机访问该应用程序,但 nafd:8001/admin 不能远程工作。
【问题讨论】:
-
Ping 不足以测试 dns 是否正常工作。运行跟踪路由。并与您分享 nginx 和 gunicorn 配置。
-
“127.0.0.0:8000”应该是什么?我猜它应该是所有 ip 地址的 0.0.0.0 或仅本地访问的 127.0.0.1。
-
@Danack,我的立场是正确的..它应该是 0.0.0.0..@Anup,我的配置与教程几乎相同。我稍后会发布我的完整配置以及跟踪路由结果
-
我完全禁用了我的防火墙和 SELINUX..但问题仍然存在
-
您是否遵循教程并使用
bin/gunicorn_start脚本启动您的应用程序?
标签: django networking nginx gunicorn centos6