Redirect alias to different servers based on port

876 Views Asked by At

I have an Oracle HTTP Server (which is based on Apache) with two applications on it:

  • http://example.net/ -> opens the Life-Application (default port 80)

  • http://example.net:7777/ -> opens the Test-Application

Now we want to simplify the URL, actually it should be like this:

  • http://application -> opens the Life-Application http://example.net/

  • http://application-t -> opens the Test-Application http://example.net:7777/

We added DNS records for application -> example.net and application-t -> example.net, however it cannot point to certain ports. (i.e. application-t -> example.net:7777 is not possible)

I tried to configure VirtualHost but I failed. Both, http://application and http://application-t are always open the Life-Application, no matter what I tried.

How to setup the VirtualHost directive? Or do I have to make it differently?

1

There are 1 best solutions below

3
On

The "ProxyPass" and "ProxyPassReverse" parameters are used to tell Apache how to proxy requests. They require the "mod_proxy.so" and "mod_proxy_http.so" Apache modules, which are loaded by default in RHEL5 and RHEL6, but check the following lines are uncommented in the "/etc/httpd/conf/httpd.conf" file to make sure. >

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_http_module modules/mod_proxy_http.so

Try Below VirtualHost Configurations

http://application -> opens the Life-Application http://example.net/

<VirtualHost *:80>

ServerName application
ServerAlias application
#DocumentRoot /var/www/html/application
ErrorLog /var/log/httpd/application-error_log
TransferLog /var/log/httpd/applicatin-access_log
ProxyPass / http://example.net/        
ProxyPassReverse / http:://example.net/ 

</VirtualHost>

http://application-t -> opens the Test-Application http://example.net:7777/

<VirtualHost *:80>

ServerName application-t
ServerAlias application-t
#DocumentRoot /var/www/html/application-t
ErrorLog /var/log/httpd/application-t-error_log
TransferLog /var/log/httpd/application-t-access_log
ProxyPass / http://example.net:7777/         
ProxyPassReverse / http:://example.net:7777/ 

</VirtualHost>

I hope it works