@joelones said in Redirect http on another port for a host override:
So what I want to accomplish is the following; I'd like for users on the network, instead of accessing services as [ip:port], to access them as such [MachineName/ServiceName].
I realize this question is old but I found it while looking for something else and this response may help someone else. What you are trying to do is often done with pfSense handling the LAN routing and Nginx or Apache handling the port routing on the local server running your services or apps.
In pfSense, services > dns resolver I use host overrides like this (example):
Host=test1, Domain=something.com, IP Address=192.168.12.20, Description="Main app/service on this server"
Then under "Additional Names for this Host" i have:
Host=test1, Domain=something2.com, Description="Main app/service2 on this server"
Host=test1, Domain=something3.com, Description="Main app/service3 on this server"
This routes LAN request targeting test1.something.com, test1.something2.com and test1.something3.com to 192.168.12.20 server. On that server I have Nginx running (same thing can be done with apache) and routing request to different service ports. Here is a basic example Nginx config for http://test1.something.com and http://www.test1.something.com being routed to a service running on server at 192.168.12.20 on port 3005 on a Ubuntu server.
# file /etc/nginx/sites-available/test1.something.com
server {
listen 80;
listen [::]:80;
server_name test1.something.com www.test1.something.com;
location / {
proxy_pass http://127.0.1.1:3005;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
The firewall on 192.168.12.20 only needs to allow external traffic from port 80 (and 443 if https) and Nginx will route to the appropriate local service port.
More information about that can be found Here and Here and Here