We have a NodeJS site running with an Apache VirtualHost that looks like this:
<VirtualHost *:80>
ServerName domain.org
ServerAlias www.domain.org
ProxyPass / http://localhost:8884/
ProxyPassReverse / http://localhost:8884/
ProxyPreserveHost on
LogLevel debug
</VirtualHost>
This works fine.
however we have now been tasked with installing a wordpress blog as an alias of the domain
www.domain.org/blog
To do this we tried setting up a vhost with an Alias like this:
<VirtualHost *:80>
Alias /blog /var/apache-vhosts/www.domain.org-blog
<Directory /var/apache-vhosts/www.domain.org-blog/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
We have the mod_alias apache module enabled but it just wont pick it up.
Has anyone else achieved this?
I have also tried including the alias without a vhost wrapping tag but still no joy :/
Note that ProxyPass
has precedence over Alias
.
To fix, declare another ProxyPass
pointing to an exclamation mark (!
).
For example:
<VirtualHost *:80>
ServerName domain.org
ServerAlias www.domain.org
# the next line is your fix
ProxyPass /blog !
Alias /blog /var/apache-vhosts/www.domain.org-blog
<Directory /var/apache-vhosts/www.domain.org-blog/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPass / http://localhost:8884/
ProxyPassReverse / http://localhost:8884/
ProxyPreserveHost on
LogLevel debug
</VirtualHost>
You can find more information in the official ProxyPass
documentation:
The ! directive is useful in situations where you don't want to reverse-proxy a subdirectory ― https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With