My server has 3 websites :
- Gitlab running with Omnibus on port 80
- React.js application in a Docker on port 3001
- Jorani (php application) on Apache on port 8008
Since DNS can’t handle the port number, how may I redirect to a port depending on the URL the user gives, for example :
- http://gitlab.domain.com => port 80
- http://react.domain.com => port 3001
- http://jorani.domain.com => port 8008
I saw some post about Proxy or reverse proxy but i’m not sure if it’s the good way to proceed
2
Answers
So here is the solution I'm using :
I changed my gitlab port to 8900. I changed my Apache port to 80.
I'm now using virtualhosts with Apache :
For CentOS 7 in /etc/httpd/sites-available/
gitlab.conf :
react.conf :
jorani.conf :
Problem : I can't manage to make it work for gitlab with SSL (gitlab.mydomain.intra => https://gitlab.mydomain.intra/). Will post the solution if I find it.
EDIT : Here is the solution for gitlab with https :
/etc/gitlab/gitlab.rb :
/etc/httpd/sites-available/gitlab.conf
In the publicly-accessible internet, HTTP traffic should be over port 80 (or over TLS that runs on port 443 for HTTPS). You can theoretically have HTTP on any port, but that is very bug-prone and not all machines support that, so it’s discouraged in production. As such you should not redirect traffic from
subdomain.domain.extension
todomain.extension:port
.Instead, you have two solutions:
The three servers run behind three IPs: each subdomain has an IP address. Each server runs behind its own IP. Your DNS server should send records for each of these domain name – IP address associations.
Reverse proxy: each subdomain goes to the same IP. Behind this IP runs a fourth server – the proxy. Its simple task is to look at the subdomain in the path and re-route the HTTP(S) traffic to the corresponding applications that it is connected to (gitlab, react, or jorani). Note that none of these three applications are directly accessible from the public internet.