Dan*_*Dan 13 ubuntu apache-2.2
我有一个带有一堆 IP 地址的服务器,我只希望 Apache 监听其中一个。这听起来并不难,我前一段时间也做过一次,但这次我遇到了一些麻烦。首先,这是我现在所处的位置,据我所知:
Apache 侦听端口 80 的每个地方,它只侦听正确的 IP。
/etc/apache2$ grep -R ":80" .
./sites-available/default:<VirtualHost 192.168.0.82:80>
./httpd.conf:<VirtualHost 192.168.0.82:80>
./ports.conf:NameVirtualHost 192.168.0.82:80
./sites-enabled/000-default:<VirtualHost 192.168.0.82:80>
Run Code Online (Sandbox Code Playgroud)
没有提到在 0.0.0.0 上听。
/etc/apache2$ grep -R "0\.0\.0\.0" .
Run Code Online (Sandbox Code Playgroud)
然而... Apache 拒绝启动。
/etc/apache2$ sudo /etc/init.d/apache2 start
* Starting web server apache2
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.
[fail]
Run Code Online (Sandbox Code Playgroud)
如果有人问,我不受该地址的约束:
/etc/apache2$ sudo netstat -nap | grep :80
tcp 0 0 192.168.0.83:80 0.0.0.0:* LISTEN 2822/node
Run Code Online (Sandbox Code Playgroud)
错误日志/var/log/apache2/error.log只是说:
[Wed Aug 08 03:30:18 2012] [notice] caught SIGTERM, shutting down
Run Code Online (Sandbox Code Playgroud)
我是否错过了 Apache 配置中的某个位置?有什么我不记得要找的东西吗?为什么这不像我记得的那么简单?
pau*_*ska 18
默认情况下,Apache 绑定到所有内容,即使您指定某些 IP 来运行 NameVirtualHost。
在你的ports.conf 中添加:
Listen 192.168.0.82:80
Run Code Online (Sandbox Code Playgroud)
参考:http : //httpd.apache.org/docs/2.2/bind.html
cjc*_*cjc 16
在/etc/apache2/ports.conf文件中查看。
你会发现一个指令,如:
Listen 80
Run Code Online (Sandbox Code Playgroud)
CentOS 框的注释描述了这个选项:
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to 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 (0.0.0.0)
#
#Listen 12.34.56.78:80
Run Code Online (Sandbox Code Playgroud)
根据您的需要,将Listen 80行更改为Listen 192.168.0.82:80.
您现在无法启动 Apache,因为它试图绑定到所有接口上的端口 80(0.0.0.0 指定),而您正在node侦听 192.168.0.83:80。
虚拟主机块中的 IP 意味着该特定虚拟主机将响应来自该 IP 地址的请求。它没有指定 Apache 如何绑定到它看到的接口。
| 归档时间: |
|
| 查看次数: |
7370 次 |
| 最近记录: |