我试图从本地网络上运行Ubuntu18.04的服务器上提供一个内部网应用程序
应用程序是用Flask编写的,我使用gunicorn命令部署了它
me@appserver:~$ authbind gunicorn -w 4 -b 127.0.0.1:80 app:appSSHing通过显示端口转发进入服务器,我可以使用火狐打开应用程序,并与其进行交互。但是,当我尝试从子网上的另一台计算机尝试时,连接将被拒绝。
我可以打电话到端口22好的。
me@clientmachine:~$ telnet 123.45.67.89 22
Trying 123.45.67.89...
Connected to 123.45.67.89.但是我在80号端口被拒绝了
me@clientmachine:~$ telnet 123.45.67.89 80
Trying 123.45.67.89...
telnet: Unable to connect to remote host: Connection refused我已经使用ufw命令配置了防火墙
me@appserver:~$ sudo ufw allow 80这给了我
me@appserver:~$ sudo ufw status
Status: active
To Action From
-- ------ ----
80 ALLOW Anywhere
80/tcp ALLOW Anywhere
22/tcp ALLOW Anywhere
80/udp ALLOW Anywhere
80 (v6) ALLOW Anywhere (v6)
80/tcp (v6) ALLOW Anywhere (v6)
22/tcp (v6) ALLOW Anywhere (v6)
80/udp (v6) ALLOW Anywhere (v6)我也证实了这一点
me@appserver:~$ netstat -an | grep :80
tcp 0 0 127.0.0.1:80 0.0.0.0:* LISTEN
me@appserver:~$ lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
gunicorn 1818 me 5u IPv4 31215 0t0 TCP localhost:http (LISTEN)
gunicorn 1822 me 5u IPv4 31215 0t0 TCP localhost:http (LISTEN)
gunicorn 1823 me 5u IPv4 31215 0t0 TCP localhost:http (LISTEN)
gunicorn 1824 me 5u IPv4 31215 0t0 TCP localhost:http (LISTEN)
gunicorn 1825 me 5u IPv4 31215 0t0 TCP localhost:http (LISTEN)和
me@appserver:~$ sudo iptables -L -n | grep :80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
ACCEPT udp -- 0.0.0.0/0 0.0.0.0/0 udp dpt:80但是,从客户端运行nmap显示为80,但表示已关闭。
me@clientmachine:~$ nmap 123.45.67.89
Starting Nmap 7.01 ( https://nmap.org ) at 2019-07-24 16:41 AEST
Nmap scan report for appserver.myuni.edu (123.45.67.89)
Host is up (0.00041s latency).
Not shown: 997 filtered ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp closed http知道为什么会这样吗?怎么解决呢?这类事情是否可以通过由网络管理员管理的子网上的设置来管理?
发布于 2019-07-24 07:40:07
消息Connection refused表示没有监听端口,端口就关闭了。如果防火墙阻止访问,您将收到一条关于超时的消息。
问题是,启动应用程序的目的是只在环回接口127.0.0.1上侦听。因此,它只在该接口上可用,您的netstat输出确认了这一点。如果您想在外部接口上使用它,则必须在启动时提供该IP,或者提供0.0.0.0以允许所有接口。
me@appserver:~$ authbind gunicorn -w 4 -b 123.45.67.89:80 app:apphttps://serverfault.com/questions/976465
复制相似问题