Apacheは127.0.0.1:80だけではなく127.*.*.*:80も処理します。

Apacheは127.0.0.1:80だけではなく127.*.*.*:80も処理します。

Apacheが127.0.0.1へのリクエストのみを処理するようにして、他のアプリケーションで127.0.0.2などを使用できるようにしたいので、/etc/apache2/sites-enabled/000-default.confを次のように変更してみました。

 <VirtualHost 127.0.0.1:80>
     ServerName localhost
     ServerAdmin webmaster@localhost
     DocumentRoot /var/www/html
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
 </VirtualHost>

その後、Apache を再起動しましたが、動作しません。他の vhost ルールは設定されていません。出力はapachectl -S次のようになります。

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
127.0.0.1:80           localhost (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default 
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33 not_used
Group: name="www-data" id=33 not_used

答え1

Listenディレクティブは、Apache httpdがバインドするアドレス/ポートの組み合わせ(または聞くポートのみが指定されている場合(アドレスなし
)、すべてのアドレスに対して指定されたポートにバインドすることを意味します。

VirtualHost一方、ディレクティブは、リクエストに応答する方法(提供するコンテンツなど)の設定の一部です。
このコンテキストで指定されるアドレス/ポートは、Apache httpd がどの着信リクエストに対してこれを使用するかを選択するために使用されますVirtualHost

Apache httpd を のみにバインドしたい場合は、onlyディレクティブ127.0.0.1:80として次のような操作を実行します。Listen

Listen 127.0.0.1:80

関連情報