首页 > 解决方案 > 无法在apache中连接本地IP地址

问题描述

我无法让 apache 使用私有 IP。

我正在尝试绑定 172.2.1,何时尝试连接让我超时

httpd.conf

Listen 172.16.2.1:8080
<VirtualHost 172.16.2.1:8080>
    ServerName 172.16.2.1
    DocumentRoot /home/user/web/domain.com/public_html
    ScriptAlias /cgi-bin/ /home/user/web/domain.com/cgi-bin/
    Alias /error/ /home/user/web/domain.com/document_errors/

    <Directory /home/user/web/domain.com/public_html>
        AllowOverride All
        Options +Includes -Indexes +ExecCGI
    </Directory>

</VirtualHost>

查看端口是否打开

# netstat -plunt | grep :8080

tcp 0 0 172.16.2.1:8080 0.0.0.0:* LISTEN 5036/apache2

我可以ping通

ping -c3 172.16.2.1

PING 172.16.2.1 (172.16.2.1) 56(84) bytes of data.
64 bytes from 172.16.2.1: icmp_seq=1 ttl=64 time=0.062 ms
64 bytes from 172.16.2.1: icmp_seq=2 ttl=64 time=0.067 ms
64 bytes from 172.16.2.1: icmp_seq=3 ttl=64 time=0.063 ms

--- 172.16.2.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 57ms
rtt min/avg/max/mdev = 0.062/0.064/0.067/0.002 ms

我正在尝试访问同一台服务器

curl -I http://172.16.2.1:8080

curl: (7) Failed to connect to 172.16.2.1 port 8080: Connection timed out

我没有启用 iptables

iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

我不知道可能出了什么问题。

标签: apachelocalhostip

解决方案


推荐阅读