17

Possible Duplicate:
How to use DNS to redirect domain to specific port on my server

My web application is running on myserver.mydomain:10000 I would like to make it available on the intranet as mywebapp.mydomain.

Reading Forward port to another Ip/port, I have looked into rinetd, but I don't fully understand how I can achieve my goal:

  1. create a cname alias mywebapp --> myserver on the name server
  2. run rinetd on myserver, redirecting port 80 to 10000 ?!?

That would redirect all http traffic.

I seem to have a gap in my understanding. Can anyone help me ?

ssc
  • 1,129
  • 3
  • 16
  • 30

3 Answers3

23

If you don't want to create another IP, then all you can do is install a reverse http proxy on the main IP and a name based virtual host to route the traffic using mod_proxy.

Here is how you can do it with apache, almost any http server can do it, other popular alternatives are squid, nginx, lighthttpd, etc.

Listen IP_ADDR:80
NameVirtualHost IP_ADDR:80

<VirtualHost IP_ADDR:80>
  ServerName  yourname.yourdomain

  ProxyPass        / http://localhost:10000/
  ProxyPassReverse / http://localhost:10000/

</VirtualHost>
Aleksandar Ivanisevic
  • 3,327
  • 19
  • 24
  • GREAT! That solves my problem, thank you very much! Tried it out right away, works like a charm. :-) – ssc Nov 16 '09 at 23:04
  • 1
    I tried this get easier access to my web app, and at first it seemed to work, but then I got all kinds of weird errors - Chrome Dev Tools were telling me that CSS and JS files were sent out with the wrong MIIME types, it complained about a stray < in jquery.js, which definitively is not there, etc. Not sure why - no problem with mimetypes when I access the server directly, must be Apache being over-active. – Stian Håklev Jul 12 '15 at 12:20
  • Hw do you achieve this using nginx? – user_mda Aug 24 '16 at 18:45
  • Does this route all traffic through the Apache server? – joshlk Jan 22 '18 at 17:12
7

DNS only maps hostnames to IP addresses, it knows nothing and can't do anything about ports.

A solution to your need could be using a NAT router/firewall to forward you'r public IP's port 80 to the internal server IP's port 10000.

Massimo
  • 68,714
  • 56
  • 196
  • 319
  • Thanks for your reply! :-) There's no public IP involved, everything happens within the intranet, one single network, no routing whatsoever. Moreover, NAT would redirect _all_ HTTP traffic, I only want to redirect mywebapp.mydomain:80 to myserver:mydomain:8080 and mywebapp does not exist as a logical host, but only as a cname (or so) – ssc Nov 16 '09 at 09:20
  • 2
    You should consider using the reverse proxy functionality of your webserver. – Antoine Benkemoun Nov 16 '09 at 09:25
  • If you're in an intranet, IP space can't be at a premium, so just allocate more IPs. – womble Nov 16 '09 at 09:37
  • You're right, I have as many IP addresses as I could possibly need. Would you care to elaborate how that helps me ? – ssc Nov 16 '09 at 22:57
  • He probably means: DNS points a name to an IP so just run each service on a separate IP, and set up a separate DNS name for each IP/service. Then run your service on the port you want it on, rather than redirecting it. – pilavdzice Jul 20 '15 at 18:53
0

I assume you're wanting just one site redirected as such, and you run other sites on port 80 already? If so, and you are not using HTTPS (SSL), then you can either set up Apache to handle this domain as mentioned, or you can teach Apache to do the forward itself, to port 10000.

I know know what server OS or http server you are using though... so can't help more.

Michael Graff
  • 6,588
  • 1
  • 23
  • 36