我已经用 apache2 从头开始在 Ubuntu 18.04 下建立了一个服务器。我配置了 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 个主机启动)
在 @pa4080 评论的帮助下,我找到了解决方案:
ufw
处于活动状态并阻止端口 80 和 443 上的连接。我暂时设置ufw
为非活动状态,连接现在正常工作。