Configure multiple domains on different ports on the same server

Asked

Viewed 1,672 times

2

I have a VPS server that is running with an Apache server (port 80), a Tomcat server (port 8090) and a 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 (at port 80 of course), when it enters dominio2.com.br it will be redirected to port x.x.x.x:8090 and when he tries to get into dominio3.com.br he would be redirected to the wildfly at port 8080.

Can you do that? I saw that you can do something similar to apache’s Virtual Host, only it only redirects between directories but not between ports...

  • I think this will help you "How to redirect DNS to Different ports"

  • @Rodrigoborth, I didn’t understand very well... in name do I put what? My main domain? And on Target (that in the case of my Cpanel is Hostname) I put the domain to which I want to redirect?

  • research a little more about SRV Records, I never had to do it so I’m not sure how to help you

1 answer

1

Set up your Apache to account for the three domains, each with its Virtual Host, directed to a specific directory.

In each directory, create a . 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 you have any difficulties, please let us know what version of your Apache.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.