1

We have two webservers, one that hosts our helpdesk web portal (helpdesk.domain.com) and the other host our company's intranet(intranet.domain.com). I am trying to configure Apache webserver hosted on the helpdesk machine(helpdesk.domain.com) to send non-helpdesk.domain.com to the intranet.domain.com. I feel like I am missing something simple because when trying access the helpdesk.DOMAIN.com outside the local network causes a redirect to intranet.DOMAIN.com.

This is my current config file for the helpdesk.DOMAIN.com apache webserver.

<VirtualHost *:80>
    ServerName intranet.DOMAIN.com
    ProxyPass http://intranet.DOMAIN.com http://192.0.1.22/ nocanon
    ProxyPassReverse http://intranet.DOMAIN.com http://192.0.1.22/
    ProxyPreserveHost on
    ErrorLog ${APACHE_LOG_DIR}/intranet_error.log
    CustomLog ${APACHE_LOG_DIR}/intranet_error.log common
</VirtualHost>

<VirtualHost *:80>
    ServerName helpdesk.DOMAIN.com
    ServerAlias helpdesk.DOMAIN helpdesk.DOMAIN www.helpdesk.DOMAIN.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/helpdesk.DOMAIN.com

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

</VirtualHost>
3
  • I think you might need to add some Rewrite conditions and Rules in the Helpdesk.domain.com section if that helps you in the meantime while you wait on a more versed Apache web server person to help you more explicitly. If it was IIS and host headers, I'd probably be able to help but not a lot of repetition with Apache on my side. Might be worth some google or searching around in case it gives you anything further to test out. Commented Aug 23, 2023 at 17:26
  • Are you trying to access these vhosts via HTTP or via HTTPS? Are you sure that the redirect is issued by Apache, and not by the proxied webapp itself? Commented Aug 23, 2023 at 17:30
  • It is via HTTP. Not 100% sure but the logs from Apache2 on the helpdesk.DOMAIN.com shows the redirect to intranet.DOMAIN.com and show all the calls and assets being accessed to the site.
    – wstrosser
    Commented Aug 23, 2023 at 17:42

1 Answer 1

1

Firstly, you will need to make sure two Apache modules are enabled, you can do so with the following command.

a2enmod proxy
a2enmod proxy_http

Then here is an example config to do what you asked for

<VirtualHost *:80>
    ServerName helpdesk.DOMAIN.com
    ServerAlias helpdesk.DOMAIN helpdesk.DOMAIN www.helpdesk.DOMAIN.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/helpdesk.DOMAIN.com

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

<VirtualHost *:80>
    ServerName intranet.DOMAIN.com
    # If someone tries to access any other domain, send them to the intranet site.
    ServerAlias *
    ProxyPass / http://192.0.1.22/
    ProxyPassReverse / http://192.0.1.22/
    ProxyPreserveHost On

    ErrorLog ${APACHE_LOG_DIR}/intranet_error.log
    CustomLog ${APACHE_LOG_DIR}/intranet_error.log common
</VirtualHost>
  • The VirtualHost for helpdesk.DOMAIN.com is placed above the intranet. This will ensure that Apache matches this configuration first if the helpdesk.DOMAIN.com domain is accessed.
  • The intranet's VirtualHost is configured with a wildcard ServerAlias (ServerAlias *). This means it will match any domain that isn't explicitly mentioned in another VirtualHost (in this case, any domain other than helpdesk.DOMAIN.com).

Don't forget to restart Apache for this configuration to take effect.

1
  • After switching the two VirutalHost around and including the ServerAlias of *. Trying to go to helpdesk.DOMAIN.com, from outside the network, results in a redirect to intranet.DOMAIN.com. I greatly appreciate the assistance and knowledge.
    – wstrosser
    Commented Aug 24, 2023 at 17:58

You must log in to answer this question.

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