Ubuntu 上的 Apache:“服务器没有响应”

Ubuntu 上的 Apache:“服务器没有响应”

我一直在排查我的 Apache 服务器,但一直没有成功。当我输入 URL 时,我得到这样的信息:浏览器无法打开页面,因为服务器没有响应。

当我在终端中尝试 curl 时,它超时了。

 curl 139.162.193.10
curl: (7) Failed to connect to 139.162.193.10 port 80: Operation timed out

traceroute 的输出:

➜  ~ traceroute www.wearenaughtypixel.co.uk
traceroute to www.wearenaughtypixel.co.uk (139.162.193.10), 64 hops max, 52 byte packets
 1  bthomehub (192.168.1.254)  72.481 ms  6.291 ms  9.498 ms
 2  * * *
 3  * * *
 4  31.55.186.176 (31.55.186.176)  10.121 ms  11.499 ms  16.226 ms
 5  core4-hu0-16-0-3.faraday.ukcore.bt.net (195.99.127.206)  13.949 ms
    core4-hu0-8-0-5.faraday.ukcore.bt.net (195.99.127.56)  14.247 ms
    core3-hu0-14-0-1.faraday.ukcore.bt.net (195.99.127.42)  25.327 ms
 6  213.137.183.32 (213.137.183.32)  14.876 ms
    213.137.183.96 (213.137.183.96)  14.341 ms
    213.137.183.38 (213.137.183.38)  13.204 ms
 7  82.112.115.185 (82.112.115.185)  12.984 ms  11.453 ms
    ldn-b3-link.telia.net (213.248.67.97)  9.699 ms
 8  ldn-bb3-link.telia.net (62.115.117.20)  12.696 ms
    ae-1.r03.londen05.uk.bb.gin.ntt.net (129.250.6.230)  10.453 ms  12.211 ms
 9  ldn-b4-link.telia.net (62.115.119.145)  10.314 ms
    ae-2.r04.londen05.uk.bb.gin.ntt.net (129.250.6.9)  10.492 ms  14.466 ms
10  linode-ic-318542-ldn-b3.c.telia.net (62.115.41.65)  10.500 ms
    ae-0.r24.londen12.uk.bb.gin.ntt.net (129.250.4.140)  14.885 ms  12.536 ms
11  switch-lon1.linode.com (109.74.207.5)  11.348 ms
    109.74.207.13 (109.74.207.13)  14.566 ms
    ae-6.r00.londen10.uk.bb.gin.ntt.net (129.250.4.21)  10.792 ms
12  * 83.217.238.86 (83.217.238.86)  26.789 ms  17.123 ms
13  * * gw-h10.linode.com (109.74.207.1)  20.029 ms
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *
31  * * *
32  * * *
33  * * *
34  * * *
35  * * *
36  * * *
37  * * *
38  * * *
39  * * *
40  * * *
41  * * *
42  * * *
43  * * *
44  * * *
45  * * *
46  * * *
47  * * *
48  * * *
49  * * *
50  * * *
51  * * *
52  * * *
53  * * *
54  * * *
55  * * *
56  * * *
57  * * *
58  * * *
59  * * *
60  * * *
61  * * *
62  * * *
63  * * *
64  * * *

网络状态

sudo netstat -ntlup
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:3306          0.0.0.0:*               LISTEN      23688/mysqld    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      30274/sshd      
tcp6       0      0 :::80                   :::*                    LISTEN      1891/apache2    

systemctl 状态 apache2

$ systemctl status apache2
● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) since Sat 2016-11-12 01:06:18 GMT; 19h ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1848 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 2880 ExecReload=/etc/init.d/apache2 reload (code=exited, status=0/SUCCESS)
  Process: 1872 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/apache2.service
           ├─1891 /usr/sbin/apache2 -k start
           ├─2912 /usr/sbin/apache2 -k start
           ├─2913 /usr/sbin/apache2 -k start
           ├─2916 /usr/sbin/apache2 -k start
           ├─2917 /usr/sbin/apache2 -k start
           ├─3118 /usr/sbin/apache2 -k start
           ├─3119 /usr/sbin/apache2 -k start
           ├─3120 /usr/sbin/apache2 -k start
           ├─3121 /usr/sbin/apache2 -k start
           ├─3122 /usr/sbin/apache2 -k start
           ├─3123 /usr/sbin/apache2 -k start
           ├─3124 /usr/sbin/apache2 -k start
           ├─3125 /usr/sbin/apache2 -k start
           ├─3126 /usr/sbin/apache2 -k start
           ├─3127 /usr/sbin/apache2 -k start
           ├─3128 /usr/sbin/apache2 -k start
           ├─3129 /usr/sbin/apache2 -k start
           ├─3130 /usr/sbin/apache2 -k start

为了解决这个问题,我应该研究最有可能的问题是什么?

我正在使用简单防火墙

$ sudo ufw status
[sudo] password for oliver: 
Status: active

To                         Action      From
--                         ------      ----
22                         ALLOW       Anywhere                  
22 (v6)                    ALLOW       Anywhere (v6) 

$ sudo iptables -vL 输出:

$ sudo iptables -vL
Chain INPUT (policy DROP 18 packets, 1291 bytes)
 pkts bytes target     prot opt in     out     source               destination         
 163K   17M f2b-sshd   tcp  --  any    any     anywhere             anywhere             multiport dports ssh
 138K   14M ufw-before-logging-input  all  --  any    any     anywhere             anywhere            
 138K   14M ufw-before-input  all  --  any    any     anywhere             anywhere            
33043 1544K ufw-after-input  all  --  any    any     anywhere             anywhere            
32969 1540K ufw-after-logging-input  all  --  any    any     anywhere             anywhere            
32969 1540K ufw-reject-input  all  --  any    any     anywhere             anywhere            
32969 1540K ufw-track-input  all  --  any    any     anywhere             anywhere            

Chain FORWARD (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ufw-before-logging-forward  all  --  any    any     anywhere             anywhere            
    0     0 ufw-before-forward  all  --  any    any     anywhere             anywhere            
    0     0 ufw-after-forward  all  --  any    any     anywhere             anywhere            
    0     0 ufw-after-logging-forward  all  --  any    any     anywhere             anywhere            
    0     0 ufw-reject-forward  all  --  any    any     anywhere             anywhere            
    0     0 ufw-track-forward  all  --  any    any     anywhere             anywhere            

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
 190K   32M ufw-before-logging-output  all  --  any    any     anywhere             anywhere            
 190K   32M ufw-before-output  all  --  any    any     anywhere             anywhere            
 1359  123K ufw-after-output  all  --  any    any     anywhere             anywhere            
 1359  123K ufw-after-logging-output  all  --  any    any     anywhere             anywhere            
 1359  123K ufw-reject-output  all  --  any    any     anywhere             anywhere            
 1359  123K ufw-track-output  all  --  any    any     anywhere             anywhere            

Chain f2b-sshd (1 references)
 pkts bytes target     prot opt in     out     source               destination         
   63  4932 REJECT     all  --  any    any     116.31.116.41        anywhere             reject-with icmp-port-unreachable
 126K   15M RETURN     all  --  any    any     anywhere             anywhere            

Chain ufw-after-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-after-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         
   31  2418 ufw-skip-to-policy-input  udp  --  any    any     anywhere             anywhere             udp dpt:netbios-ns
    0     0 ufw-skip-to-policy-input  udp  --  any    any     anywhere             anywhere             udp dpt:netbios-dgm
    7   336 ufw-skip-to-policy-input  tcp  --  any    any     anywhere             anywhere             tcp dpt:netbios-ssn
   36  1776 ufw-skip-to-policy-input  tcp  --  any    any     anywhere             anywhere             tcp dpt:microsoft-ds
    0     0 ufw-skip-to-policy-input  udp  --  any    any     anywhere             anywhere             udp dpt:bootps
    0     0 ufw-skip-to-policy-input  udp  --  any    any     anywhere             anywhere             udp dpt:bootpc
    0     0 ufw-skip-to-policy-input  all  --  any    any     anywhere             anywhere             ADDRTYPE match dst-type BROADCAST

Chain ufw-after-logging-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 LOG        all  --  any    any     anywhere             anywhere             limit: avg 3/min burst 10 LOG level warning prefix "[UFW BLOCK] "

Chain ufw-after-logging-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         
26055 1221K LOG        all  --  any    any     anywhere             anywhere             limit: avg 3/min burst 10 LOG level warning prefix "[UFW BLOCK] "

Chain ufw-after-logging-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-after-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-before-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  any    any     anywhere             anywhere             ctstate RELATED,ESTABLISHED
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp destination-unreachable
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp source-quench
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp time-exceeded
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp parameter-problem
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp echo-request
    0     0 ufw-user-forward  all  --  any    any     anywhere             anywhere            

Chain ufw-before-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  lo     any     anywhere             anywhere            
91131   11M ACCEPT     all  --  any    any     anywhere             anywhere             ctstate RELATED,ESTABLISHED
  259 12953 ufw-logging-deny  all  --  any    any     anywhere             anywhere             ctstate INVALID
  259 12953 DROP       all  --  any    any     anywhere             anywhere             ctstate INVALID
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp destination-unreachable
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp source-quench
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp time-exceeded
    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp parameter-problem
  268 15308 ACCEPT     icmp --  any    any     anywhere             anywhere             icmp echo-request
    0     0 ACCEPT     udp  --  any    any     anywhere             anywhere             udp spt:bootps dpt:bootpc
45965 2305K ufw-not-local  all  --  any    any     anywhere             anywhere            
    0     0 ACCEPT     udp  --  any    any     anywhere             224.0.0.251          udp dpt:mdns
    0     0 ACCEPT     udp  --  any    any     anywhere             239.255.255.250      udp dpt:1900
45965 2305K ufw-user-input  all  --  any    any     anywhere             anywhere            

Chain ufw-before-logging-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-before-logging-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-before-logging-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-before-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  any    lo      anywhere             anywhere            
 189K   32M ACCEPT     all  --  any    any     anywhere             anywhere             ctstate RELATED,ESTABLISHED
 1359  123K ufw-user-output  all  --  any    any     anywhere             anywhere            

Chain ufw-logging-allow (0 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 LOG        all  --  any    any     anywhere             anywhere             limit: avg 3/min burst 10 LOG level warning prefix "[UFW ALLOW] "

Chain ufw-logging-deny (2 references)
 pkts bytes target     prot opt in     out     source               destination         
  238 11693 RETURN     all  --  any    any     anywhere             anywhere             ctstate INVALID limit: avg 3/min burst 10
   10   600 LOG        all  --  any    any     anywhere             anywhere             limit: avg 3/min burst 10 LOG level warning prefix "[UFW BLOCK] "

Chain ufw-not-local (1 references)
 pkts bytes target     prot opt in     out     source               destination         
45965 2305K RETURN     all  --  any    any     anywhere             anywhere             ADDRTYPE match dst-type LOCAL
    0     0 RETURN     all  --  any    any     anywhere             anywhere             ADDRTYPE match dst-type MULTICAST
    0     0 RETURN     all  --  any    any     anywhere             anywhere             ADDRTYPE match dst-type BROADCAST
    0     0 ufw-logging-deny  all  --  any    any     anywhere             anywhere             limit: avg 3/min burst 10
    0     0 DROP       all  --  any    any     anywhere             anywhere            

Chain ufw-reject-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-reject-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-reject-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-skip-to-policy-forward (0 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 DROP       all  --  any    any     anywhere             anywhere            

Chain ufw-skip-to-policy-input (7 references)
 pkts bytes target     prot opt in     out     source               destination         
   74  4530 DROP       all  --  any    any     anywhere             anywhere            

Chain ufw-skip-to-policy-output (0 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  any    any     anywhere             anywhere            

Chain ufw-track-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-track-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-track-output (1 references)
 pkts bytes target     prot opt in     out     source               destination         
  659 76027 ACCEPT     tcp  --  any    any     anywhere             anywhere             ctstate NEW
   26  1761 ACCEPT     udp  --  any    any     anywhere             anywhere             ctstate NEW

Chain ufw-user-forward (1 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-user-input (1 references)
 pkts bytes target     prot opt in     out     source               destination         
12922  761K ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:ssh
    1    57 ACCEPT     udp  --  any    any     anywhere             anywhere             udp dpt:ssh

Chain ufw-user-limit (0 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 LOG        all  --  any    any     anywhere             anywhere             limit: avg 3/min burst 5 LOG level warning prefix "[UFW LIMIT BLOCK] "
    0     0 REJECT     all  --  any    any     anywhere             anywhere             reject-with icmp-port-unreachable

Chain ufw-user-limit-accept (0 references)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  any    any     anywhere             anywhere            

Chain ufw-user-logging-forward (0 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-user-logging-input (0 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-user-logging-output (0 references)
 pkts bytes target     prot opt in     out     source               destination         

Chain ufw-user-output (1 references)
 pkts bytes target     prot opt in     out     source               destination

答案1

肯定是防火墙问题。您的 ssh 服务器有响应,但我无法访问您的 TCP 端口 80。


更新 :

TCP 端口 80 未打开。相关 Linode 文档对此提出了一些建议。

iptables -A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT

或者正如@Ollie_W 指出的那样:

ufw allow 80/tcp

相关内容