Apache:我怎样才能在www.example.com上看到我的本地主机192.168.1.101192.168.1.102?

fsi0uk1n  于 2022-11-16  发布在  Apache
关注(0)|答案(1)|浏览(192)

我在Ubuntu上运行Apache。我的IP地址是192.168.1.101
虽然http://localhosthttp://192.168.1.101在我的PC中运行良好,但我无法使用http://192.168.1.102从笔记本电脑中访问它
很奇怪。我可以ping 192.168.1.101,但我在浏览器中看到“连接已超时”。
我使用的是默认的apache配置,所以我的sites-available/default如下所示:

NameVirtualHost *:80
<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /home/www/public_html
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /home/www/public_html>
        Options Indexes FollowSymLinks MultiViews
        #AllowOverride None
        AllowOverride all
        Order allow,deny
        allow from all

    </Directory>

/etc/apache2/posrts.conf名称虚拟主机 *:80侦听80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

我的笔记本电脑也运行Ubuntu。所以我不认为这是防火墙的问题。
在笔记本电脑(192.168.1.102)中执行的命令:

adp@adp-laptop:~$ ping 192.168.1.101
PING 192.168.1.101 (192.168.1.101) 56(84) bytes of data.
64 bytes from 192.168.1.101: icmp_seq=1 ttl=64 time=32.1 ms
64 bytes from 192.168.1.101: icmp_seq=2 ttl=64 time=54.8 ms
64 bytes from 192.168.1.101: icmp_seq=3 ttl=64 time=77.0 ms
64 bytes from 192.168.1.101: icmp_seq=4 ttl=64 time=100 ms
^C
--- 192.168.1.101 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 32.193/66.193/100.717/25.463 ms

adp@adp-laptop:~$ telnet 192.168.1.101 80
Trying 192.168.1.101...
telnet: Unable to connect to remote host: Connection timed out

在PC(192.168.1.101)中执行的命令:

adp@adp-desktop:~$ ps afx | grep http
12672 pts/4    S+     0:00              |               \_ grep --color=auto http

adp@adp-desktop:~$ ping 192.168.1.102
PING 192.168.1.102 (192.168.1.102) 56(84) bytes of data.
64 bytes from 192.168.1.102: icmp_seq=1 ttl=64 time=32.1 ms
64 bytes from 192.168.1.102: icmp_seq=2 ttl=64 time=54.8 ms
64 bytes from 192.168.1.102: icmp_seq=3 ttl=64 time=77.0 ms
64 bytes from 192.168.1.102: icmp_seq=4 ttl=64 time=100 ms
^C
--- 192.168.1.102 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 32.193/66.193/100.717/25.463 ms
adp@adp-desktop:~$ telnet 192.168.1.102 80
Trying 192.168.1.102...
telnet: Unable to connect to remote host: Connection refused
adp@adp-desktop:~$ telnet 192.168.1.102
Trying 192.168.1.102...
telnet: Unable to connect to remote host: Connection refused

我该怎么办?

cwtwac6a

cwtwac6a1#

因为连接超时(不是拒绝),我猜这是一个防火墙问题检查,如果你正在使用任何。
如果你的内核对关闭的端口使用了 * 黑洞 *(它不会发送 * 连接被拒绝 * 的TCP包,只是在端口未被使用时拒绝回答任何问题),还有一种可能性。但是你提到你的配置文件中有Listen 80,这意味着所有接口,所以你很有可能遇到了防火墙问题。
在UFW(Ubuntu中的默认防火墙)中,您可以添加防火墙规则以允许传入的HTTP连接到您的设备:

sudo ufw allow proto tcp from any to 192.168.1.101 port 80

相关问题