Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

This question already has an answer here:

I have a linux computer accessible from the internet and I have registered a free dynamic DNS service, let's say its address on the internet is xx.yy.com.

On this computer I have two processes listening: tomcat on port 80 and a small program written by myself on 8080.

As expected I can reach these two respectively with the URLs "xx.yy.com" and "xx.yy.com:8080". I would like to set up a third-level domain to bind to the 8080 port, so that when I type (e.g.) "aa.xx.yy.com" on a browser it has the same effects of "xx.yy.com:8080".

I have no clue on how to do that, can it be done via tomcat configuration (I would rather it be a system configuration than having to rely on tomcat)?

Do I have to set up some daemon to do it for me (I have read about bind)?

Can it be done so that the port 8080 is hidden? I have realized that my work network blocks outgoing connections on ports that are not 80 or 443. So I figured out that a good solution to that may be to move tomcat on another port and put something on 80 to internally redirect traffic to the correct socket. Can it be done? How? Any guide around?

Thank you

share|improve this question

marked as duplicate by cjm, Anthon, Zelda, slm, Timo Feb 14 at 17:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Your DDNS service is allowing you to create "aa.xx.yy.com", correct? –  WhiteHotLoveTiger Feb 14 at 15:38
    
I should check again but I remember it didn't allow me to specify a port. What if I set my own DNS? Will my definitions be exported to other DNS servers? –  capitano666 Feb 17 at 10:03
    
Where ports are concerned, your DDNS service doesn't care, and doesn't even have the capabilities to interfere with the ports you're using. Everything related to which ports you have services listening on is done on your server. As far as the DNS records for your subdomain, if you want it to be a publicly accessible subdomain, I think you'll need to set it up through your DDNS service provider. –  WhiteHotLoveTiger Feb 17 at 14:02

2 Answers 2

up vote 1 down vote accepted

You could look into SRV Records, but your question is fundamentally missing what DNS actually does.

Notwithstanding the aforementioned SRV Recrod, all DNS does is translate a name (e. g. host.example.com) to an IP address (169.254.1.2); nothing more. It's a "network phone book". It doesn't know or care about individual ports on a host which is assigned to an IP address.

That said, there are ways to do what you ask:

  • Apache VirtualHosts which proxy to the desired location
  • Web pages that set up a full-window IFRAME which loads the desired location in a frams
  • iptables or other firewall shenannigans
share|improve this answer
    
I see, I thought the DNS just translated the "example.com" part, and then the server on "example.com" redirected to "host". The iptables way of doing it interests me, any more detail on that? –  capitano666 Feb 15 at 20:15
1  
You can tell iptables to listen for an inbound connection on port 80, and forward it to an internal IP address or loopback address on port 8080. I don't have the exact incantation for this off the top of my head, as I usually use VirtualHosts for this sort of thing, and the Shoreline Firewall to handle iptables for me, as I'm lazy. (: –  DopeGhoti Feb 21 at 20:12

This can be achieve using Apache ProxyPass module

This Steps for Ubuntu Server

Step 1# Install ProxyPass module

  • sudo apt-get install libapache2-mod-proxy-html libxml2-dev

Step 2# Enable module

  • a2enmod proxypass

  • a2enmod proxy

Step 3# Define following directives in Respective Virtual Container

NameVirtualHost *:80
<VirtualHost aa.xx.yy.com:80>
     ServerAdmin support@aa.xx.yy.com
     ServerName aa.xx.yy.com

     ProxyRequests On
     ProxyPass /   http://xx.yy.com:8080
     ProxyPassReverse /   http://xx.yy.com:8080

     # Uncomment the line below if your site uses SSL.
     #SSLProxyEngine On
</VirtualHost>

Step 4# reload apache

  • /etc/init.d/apache2 reload

Now test your URL and check error logs if there is any issue while loading web page

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.