在 Ubuntu 18.04 上安装了 apache2,启动它,它响应来自本地主机的请求,但不响应来自外部的请求

在 Ubuntu 18.04 上安装了 apache2,启动它,它响应来自本地主机的请求,但不响应来自外部的请求

我已经在 Ubuntu 18.04 下使用 apache2 从头开始​​设置了一个服务器。我配置了 apache2,并且能够启动它。

我可以确认它正在运行

prompt:~$ apachectl status
              Apache Server Status for localhost (via ::1)

Server Version: Apache/2.4.29 (Ubuntu) mod_fcgid/2.3.9 OpenSSL/1.1.0g
Server MPM: prefork
Server Built: 2018-10-10T18:59:25
  __________________________________________________________________

Current Time: Monday, 18-Mar-2019 18:42:58 CET
Restart Time: Monday, 18-Mar-2019 16:13:58 CET
Parent Server Config. Generation: 1
Parent Server MPM Generation: 0
Server uptime: 2 hours 28 minutes 59 seconds
Server load: 0.00 0.00 0.00
Total accesses: 3 - Total Traffic: 22 kB
CPU Usage: u0 s0 cu0 cs0
.000336 requests/sec - 2 B/second - 7.3 kB/request
1 requests currently being processed, 5 idle workers

____W_..........................................................
................................................................
......................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

我可以在本地访问它

 prompt:~$ wget localhost
 --2019-03-18 18:45:31--  http://localhost/
 Resolving localhost (localhost)... ::1, 127.0.0.1
 Connecting to localhost (localhost)|::1|:80... connected.
 HTTP request sent, awaiting response... 200 OK
 Length: 10918 (11K) [text/html]
 Saving to: ‘index.html’

 index.html          100%[===================>]  10.66K  --.-KB/s    in 0s      

 2019-03-18 18:45:31 (139 MB/s) - ‘index.html’ saved [10918/10918]

但我无法从外部访问它。任何来自外部的连接都只是超时,不会立即被拒绝,也不会因为“网络不可达”而失败。从外部尝试的访问既未登录/var/log/apache2/access.log也未登录/var/log/apache2/error.log。这种行为的原因是什么?我该如何修复它?

编辑:更多关于网络的信息:服务器位于大学网络中,通过防火墙配置应该对整个网络的公众可见。我尝试使用firefox和访问它wget,结果相同。我尝试了“近邻”和外部计算机。

EDIT2:输出来自nmap

 Starting Nmap 7.60 ( https://nmap.org ) at 2019-03-18 19:16 CET
 Nmap scan report for localhost (127.0.0.1)
 Host is up (0.00021s latency).
 Other addresses for localhost (not scanned): ::1
 rDNS record for 127.0.0.1: localhost.localdomain
 Not shown: 992 closed ports
 PORT     STATE SERVICE
 22/tcp   open  ssh
 25/tcp   open  smtp
 80/tcp   open  http
 443/tcp  open  https
 587/tcp  open  submission
 3306/tcp open  mysql
 7937/tcp open  nsrexecd
 7938/tcp open  lgtomapper

Nmap 完成:0.13 秒内扫描了 1 个 IP 地址(1 个主机启动)

答案1

在@pa4080 的评论的帮助下,我找到了解决方案:ufw处于活动状态并阻止端口 80 和 443 上的连接。我ufw暂时将其设置为非活动状态,现在连接正在运行。

相关内容