Skip to main content

Apache handles 127.*.*.*:80 instead of just 127.0.0.1:80 [Resolved]

I'd like Apache to only handle requests to 127.0.0.1 so that I can use 127.0.0.2 etc. for other applications, so I've tried changing the /etc/apache2/sites-enabled/000-default.conf to

 
     ServerName localhost
     ServerAdmin webmaster@localhost
     DocumentRoot /var/www/html
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
 

and then I've restarted Apache, but it doesn't work. No other vhost rules are in place, output of apachectl -S is as follows:

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

Question Credit: a51
Question Reference
Asked July 21, 2019
Posted Under: Network
20 views
1 Answers

The Listen directive is used to configure which address/port combinations that Apache httpd should bind to (or listen on, if you will).
When only a port is specified (no address), that means to bind to the specified port for all addresses.

The VirtualHost directive, on the other hand, is part of the configuration for how to respond to requests (like what content to serve, etc).
The address/port that is specified in this context is used to select for which incoming requests that Apache httpd should even attempt to use this VirtualHost.

If you only want Apache httpd to only bind to 127.0.0.1:80, you would do something like this as your only Listen directive:

Listen 127.0.0.1:80

credit: Håkan Lindqvist
Answered July 21, 2019
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA