0

I was trying a few thing for a custom "default" Apache vhost and nothing seemed to work, I always got the /var/www/html/index.html served instead of other contents or errors I wanted to display.

But the most bizarre thing: every access log got recored into /var/log/apache2/other_vhosts_access.log instead of /var/log/apache2/access.log.

I tried resetting my install by removing completly Apache (not sure if this was enough)...

systemctl stop apache2
apt-get remove --purge apache2
rm -rf /etc/apache2
rm -rf /var/log/apache2
rm -rf /var/www/html
deluser --remove-home www-data
apt autoremove

... then reinstalling it and only changing the port (because I use nginx as a reverse-proxy):

apt install apache2
sed -i 's/Listen 80/Listen 8080/' /etc/apache2/ports.conf

So I now have only one existing vhost presnt on this install: 000-default.conf (in its original state) and it is active (checked apache2ctl -S).

And even after that, any call to my webserver is still rerouted by nginx to Apache (that's OK) that still logs anything to /var/log/apache2/other_vhosts_access.log, which indicates (to my understanding) that the vhost is not trigger by Apache (that's not OK).

Isn't it a "catchall" vhost, that should be trigger by any Host header sent to it? Why woulnd't it be trigger in this case?

I tested a bit with apache2.conf's LogLevel debug and looked into /var/log/apache2/error.log and /var/log/syslog, but I didn't see anything that seemed releven (I can still post the whole thing if any of you think it might help).

1 Answer 1

0

I'm a idiot... The problem was caused by the only thing that differ from the default install!

If Apache isn't listening to port 80, but port 8080 (because it is behind a nginx reverse-proxy that holds the access to port 80), then all Apache vhosts must be set accordingly.

Apache conf always mentions ports in two places:

  • Listen 80 in /etc/apache2/ports.conf
  • <VirtualHost *:80> in all vhosts in /etc/apache2/sites-available/*.conf (or sites-enabled)

To update the port for both:

# Replace "Listen 80" by "Listen 8080" in ports.conf
sed -i '/^Listen 80$/ s/80/8080/' /etc/apache2/ports.conf

# Replace "<VirtualHost *:80>" by "<VirtualHost *:8080>" in all vhosts
sed -i 's/:80>/:8080>/' /etc/apache2/sites-available/*.conf

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .