0

I have an ip like username.dyndns.org, this is the external IP of my router. On my lan, I have several machine (m1, m2, ...) , each running a dedicated web server. Is it possible to reach each machine from the outside with something like: http://m1.username.dyndns.org http://m2.username.dyndns.org ? Do you know what needs to be configured in my router for NAT ? Also, is there a special directive in Apache to do so ? Thanks a lot, Regards, Luc

3 Answers 3

1

Here is what you need to do to get what you want:

  1. Setup dyndns to create a wildcard (*) CNAME for your domain. I beleive this requires their pro version. This will cause dyndns to resolve anything.username.dyndns.org to your router's public IP. Since my Comcast IP rarely changes, I don't use dyndns, but rather directly edit the DNS entries via my domain registrar (godaddy) which is free with domain name purchase.

  2. Setup your router to forward ALL port 80 traffic to a single machine/VM running Apache. This is where all of your virtual hosts are defined. Within each virtualhost section, set up a proxy to the actual machine that handles that subdomain

5
  • Hello Mark, I will setup your solution. In fact, to be more precise, I have a physical machine m and multiple VMs within that machine. The VMS are the m1, m2, ... machines I was talking about. Do you think I can setup a apache server on the machine m and create virtualhost for each hosts existing on the m1,m2 ... machines ? Same thing for ssh with ssh forward or something like that ? Thanks a lot,Luc
    – Luc
    Mar 18, 2010 at 13:22
  • I just answered a similar question on how to use a Apache front-end to app servers in VM's. You can use a similar setup for Apache instances in VM's: serverfault.com/questions/122636/reverse-proxy-ftp-traffic/… In your case your physical machine would host the "VM1 - web" box and you would run apache in your "dom1/2" boxes. I would recommend setting up virtualhost + mod_proxy on the host machine and then setup the VM's as if they are the sole owner of the domain. Mar 19, 2010 at 17:19
  • The reason for this is that proxying strips the original requested domain name which breaks virtualhosting on the VM's. If you really need this use the ProxyPreserveHost directive to preserve the originally requested host Mar 19, 2010 at 17:24
  • SSH will be a pain, unless you are willing to assign a different port for each VM. I don't know of any virtualhost like solution for SSH. Basically you run SSH on a custom port for each VM and then set up port-forwarding on the router for each custom port. Mar 19, 2010 at 17:28
  • Thanks a lot Mark. I submitted a dedicated question for ssh stuff before I read your answer. Well, I would have prefered to forward the request instead of playing with the ports... hum... it seems that I do not have any other choices then... Thanks a lot, Luc
    – Luc
    Mar 21, 2010 at 13:52
1

Yes, it's possible. Just add a ruleset to the NAT table on your router that points to the IP of webserver using port 80. There is also a section on the router which you can define your dyndns redirection to refresh your IP every 30 mins.

1
  • Hello, thanks for your answer. But, how will it know the targetted machine, m1, m2, ... ?
    – Luc
    Mar 17, 2010 at 15:19
1

Syuuske has the networking right.

To make many domains answer on one ip address you'll need to setup a proxy for your other machines.

If you were to use apache for this, create a name based virtual host for each domain you want apache to answer for and use mod_proxy to forward requests on to the correct machine.

http://httpd.apache.org/docs/2.1/vhosts/name-based.html

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

Some residential hosting companies in the states (suddenlink and time warner) block inbound traffic on port 80, so if you can't get it working on 80, try another port.

Good luck.

4
  • Hello, thanks for you answer. In fact, each machine (m1, m2, ...) behind my router is running its own apache. Each apache conf have several NameBased Virtualhost. Maybe I was not that clear (in fact I am not sure this is clear in my head :-) ). If I want to call service_m1 (beeing the first apache NAme nased Virtual host running on m1), what do I need to do to be able to call it from the internet with: service1_m1.username.dyndns.org. Same thing for service2_m3.username.dyndns.org (service2 beeing the 2nd Named Based Virtual Host running on machine m3). Thanks a lot for your help
    – Luc
    Mar 17, 2010 at 15:34
  • Mark explained more clearly. Here is a diagram. gliffy.com/pubdoc/2031679/L.png
    – txyoji
    Mar 17, 2010 at 17:22
  • I am not that familiar with proxy, but I will surely dive into this and set up this configuration. Thanks a lot guys, that will help me a lot. By the way, if i need to ssh any of the m1, m2, ... machine from outside, what could be done ? Thanks again, Luc
    – Luc
    Mar 18, 2010 at 8:57
  • To be more accurate, what could be done to be able to issue the command ssh [email protected], ssh [email protected] ? Thanks again, Luc ps: I will start by upgrading to dyndns pro for the CNAME wildcard :-)
    – Luc
    Mar 18, 2010 at 9:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .