【发布时间】:2018-11-03 21:07:39
【问题描述】:
我在 Centos7 上构建了一个基本的 Django 项目和应用程序,但我无法从外部访问它。检查下面的配置。
[root@pytoncentos7 myproject]# cat settings.py | grep ALLOWED
ALLOWED_HOSTS = ['*']
我运行我的服务器如下。
[root@pytoncentos7 myproject]# python3.6 manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
May 24, 2018 - 15:03:04
Django version 2.0.5, using settings 'myproject.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
另外,防火墙没有运行
[root@pytoncentos7 myproject]# firewall-cmd --state
not running
下面是我的端口列表。
[root@pytoncentos7 myproject]# netstat -lptun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
PID/Program name
tcp 0 0 127.0.0.1:8000 0.0.0.0:* LISTEN
1643/python3.6
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
876/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
982/master
tcp6 0 0 :::3306 :::* LISTEN
986/mysqld
tcp6 0 0 :::22 :::* LISTEN
876/sshd
tcp6 0 0 ::1:25 :::* LISTEN
982/master
udp 0 0 127.0.0.1:323 0.0.0.0:*
636/chronyd
udp6 0 0 ::1:323 :::*
636/chronyd
另外,当我尝试从外部连接到端口 8000 时,它失败了!!。但是我当然可以在本地远程登录。同时,我在 80 上运行 Apache 并且可以从内部/外部访问,但是当我禁用 Apache 并在端口 80 上运行 Django 时,我仍然可以在本地连接但不能在外部连接
Django 服务器只是在我的本地计算机上运行的虚拟机
【问题讨论】:
-
您需要打开路由器上的端口
标签: python django centos7 telnet firewall