Configure multiple domains on different ports on the same server

2

I have a VPS server that is running with an Apache server (port 80), a Tomcat server (port 8090), and Wildfly on port 8080.

But I wanted to know if there is a way to configure a domain for each port, for example: My server has ip x.x.x.x , when the user enters dominio1.com.br it will be redirected to that ip (on port 80 clear ), when it enters dominio2.com.br it will be redirected to x.x.x.x:8090 port and when it tries to enter dominio3.com.br it would be redirected to wildfly on port 8080.

Can you do that? I saw that it has something like Apache Virtual Host, but it only redirects between directories but not between ports ...

    
asked by anonymous 20.10.2014 / 18:15

1 answer

1

Configure your Apache to respond to the three domains, each with its Virtual Host, each directed to a specific directory.

In each directory, create an .htaccess file with the following specifications:

1) .htaccess for domain1:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domminio1.com.br$ [OR]
RewriteCond %{HTTP_HOST} ^www.dominio1.com.br$
RewriteRule ^.*$ "http\:\/\/x\.x\.x\.x\:80%{REQUEST_URI}" [P,QSA,L]

2) .htaccess for domain2:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^dominio2.com.br$ [OR]
RewriteCond %{HTTP_HOST} ^www.dominio2.com.br$
RewriteRule ^.*$ "http\:\/\/x\.x\.x\.x\:8090%{REQUEST_URI}" [P,QSA,L]

3) .htaccess for domain3:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domminio3.com.br$ [OR]
RewriteCond %{HTTP_HOST} ^www.dominio3.com.br$
RewriteRule ^.*$ "http\:\/\/x\.x\.x\.x\:8080%{REQUEST_URI}" [P,QSA,L]

If there is any difficulty, please tell us the version of your Apache.

    
21.10.2014 / 19:16