我已经设置了一个 apache2 服务器,它可以成功地处理对我的特定 IP a-la 的请求curl -i -H GET http://a.b.c.d/nominatim/lookup.php?osm_ids=N107775&format=json
,但对 localhost (a-la) 的请求(来自同一个服务器)curl -i -H GET http://localhost/nominatim/lookup.php?osm_ids=N107775&format=json
会失败并出现 403 错误,而且这些错误不会记录在 /var/log/apache2/error.log 中。
有人知道断开连接可能在哪里吗?我的 /etc/apache2/sites-enabled/osm.conf 如下所示:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName server.floob.com
ServerAlias osm-floob.floob.com
DocumentRoot /home/jeremy/Nominatim-3.2.0/build/website
ErrorLog /home/jeremy/Nominatim-3.2.0/build/website/apache.error.log
CustomLog /home/jeremy/Nominatim-3.2.0/build/website/apache.custom.log combined
</VirtualHost>
<Directory "/home/jeremy/Nominatim-3.2.0/build/website">
Options FollowSymLinks MultiViews
AddType text/html .php
DirectoryIndex search.php
Require all granted
Order allow,deny
Allow from all
</Directory>
Alias /nominatim /home/jeremy/Nominatim-3.2.0/build/website
答案1
检查您的 httpd.conf(您在其中配置您正在监听的端口),如果您错误地指定了 IP abcd。
文档告诉你
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 0.0.0.0:80
#Listen [::]:80
您可以配置
Listen 0.0.0.0:80
或者
Listen 80
使用所有 NIC 监听端口 80,但如果只指定一个 IP 地址,服务器将不会绑定到本地主机 (127.0.0.1)。