简体   繁体   中英

HTTP Requests going to wrong VirtualHost apache2

Hoping someone can lend me a hand here as this has been bugging me for a few days now.

I have a apache config file, it does both standard HTTP server work as well as reverse proxy for pages within the network.

If i create a new DNS A record for the IP address of the apache server it will automatically send the request to the camera1.domainname.com virtual host and then forward me 192.168.2.160.

What i want it to to do is send it to the folder /var/www/bad_url.

Any suggestions here would be great as im pretty sure im going to start loosing hair.

NameVirtualHost *

ErrorLog ${APACHE_LOG_DIR}/error_baduri.log
CustomLog ${APACHE_LOG_DIR}/access_baduri.log combined
DocumentRoot /var/www/bad_url

ProxyPreserveHost On

ErrorLog ${APACHE_LOG_DIR}/error_cam1.log
CustomLog ${APACHE_LOG_DIR}/access_cam1.log combined
LogLevel debug


ProxyPass / http://192.168.2.160/
ProxyPassReverse / http://192.168.2.160/

ServerAlias camera1.domainname.com

ProxyPreserveHost On

ErrorLog ${APACHE_LOG_DIR}/error_mediaserver.log
CustomLog ${APACHE_LOG_DIR}/access_mediaserver.log combined
LogLevel debug


ProxyPass / http://192.168.2.207/
ProxyPassReverse / http://192.168.2.207/

ServerAlias mediaserver.domainname.com

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

ServerAlias ubuntu1 ubuntu1.domainname.com 192.168.2.208

DocumentRoot /var/www/html

All the above is in file 'etc/apache2/sites-enabled/default.conf'. There are no other config files in that folder.

Im running Ubuntu

Just quickly. it seems order matters. As long as i have the wild card up the top it went there first unless another virtual host matched the criteria. weird.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM