我在运行 raspbian 的 Raspberry Pi 上安装了 apache2。然后我配置了路由器,将端口 80 和 443 映射到 Pi 上的相同端口 (192.168.2.108)。
从我的 Pi 本身,我可以通过输入 localhost 或 127.0.0.1 或其本地 ip (192.168.2.108) 或我的路由器的外部 ip 来访问 apache 测试页面。
从我的笔记本电脑上,我只能通过输入路由器的外部 IP 地址来访问该页面,但是不是通过输入我的 Pi 的内部 IP (192.168.2.108)。
知道原因吗?以下是一些可能很重要的信息:
$ apache2 -v
Server version: Apache/2.4.10 (Raspbian)
Server built: Jul 20 2016 10:31:40
$ sudo /etc/init.d/apache2 status
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2)
Active: active (exited) since Sa 2016-09-10 12:35:22 UTC; 21min ago
Process: 1128 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
Process: 1140 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
Sep 10 12:35:22 raspberrypi apache2[1140]: Starting web server: apache2AH005...e
Sep 10 12:35:22 raspberrypi apache2[1140]: (99)Cannot assign requested addre...0
Sep 10 12:35:22 raspberrypi apache2[1140]: no listening sockets available, s...n
Sep 10 12:35:22 raspberrypi apache2[1140]: AH00015: Unable to open logs
Sep 10 12:35:22 raspberrypi apache2[1140]: Action 'start' failed.
Sep 10 12:35:22 raspberrypi apache2[1140]: The Apache error log may have mor....
Sep 10 12:35:22 raspberrypi apache2[1140]: .
Sep 10 12:35:22 raspberrypi systemd[1]: Started LSB: Apache2 web server.
Hint: Some lines were ellipsized, use -l to show in full.
$ sudo 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
$ sudo netstat -ntlp
Aktive Internetverbindungen (Nur Server)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 457/sshd
tcp6 0 0 :::80 :::* LISTEN 1422/apache2
tcp6 0 0 :::22 :::* LISTEN 457/sshd
$ cat /etc/apache2/ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 80
#Listen 192.168.2.107:80
#Listen 8000
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
/etc/apache2/apache.conf(删除了一些注释):
#ServerRoot "/etc/apache2"
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
# Include list of ports to listen on
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
编辑:
有趣的新信息:我可以使用 192.168.2.108 从我的智能手机访问测试页面!如果我使用 Chromium 而不是 Firefox,它也可以在我的笔记本电脑上使用。
答案1
谢谢你的提示,sinclair!这与代理无关。但当我搜索代理设置时,我发现了这一点Firefox 帮助页面并尝试了每一步。最后一个解决了我的问题:
我必须清除 cookies 和缓存。