I have tried to configure Apache virtual hosts to respond to connections on all of my network interfaces (external, private, loopback) on port 8080, but to no luck. Here's what I have done so far on my MacOS Monterey:
Made sure the virtual host module is enabled in httpd.conf
by uncommenting the #
Read and followed the official Apache documentation https://httpd.apache.org/docs/2.4/vhosts/ on virtual hosts.
Temporarily Disabled Firewall
The virtual hosts file is listening to port 8080 on all network interfaces (Listen 8080).
The virtual hosts file (using IP-Based virtual hosts) looks like this:
Listen 8080
<VirtualHost *:8080>
DocumentRoot <pathToDirectory>
ServerName <someName>
<Directory <sameAsDocumentRoot>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
To test, I stopped the web server using brew services stop httpd
and started it again with brew services start httpd
. I visited both 127.0.0.1:8080
and 192.168.1.2:8080
(private ip) on Chrome which both lead to the status message:
The requested URL / was not found on this server.
However, visiting localhost:8080
successfully retrieves my webpage.
My question then is how can I make Apache bind to all network interfaces (on port 8080) and be able to access the associated IP addresses on a web browser by configuring virtual hosts? Explicit IP address mappings work but is it possible to have a single <VirtualHost>
directive that can respond to requests from any network interface? Any help will be much appreciated!