SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict mmanders's Avatar
    Join Date
    Jul 2006
    Location
    Edinburgh, Scotland
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Home Server-IP or Name VirtualHosts

    I have a web server running Apache and soon Tomcat. It is behind my firewall box so in order to grant access to various virtual host sites to the outside world I would need to use port forwarding on my firewall box. Given this situation, I presume my virtual hosts would have to be IP based in order to forward a particular iport to the web server? Does this mean that my web server box would need multiple IP addresses assigned to the NIC, and if so is there any easy way to manager this, or do I just have to add a new IP and virtual host everytime I create a new site?

    Many Thanks,
    Max

  2. #2
    SitePoint Enthusiast lkagan's Avatar
    Join Date
    Sep 2007
    Location
    Boca Raton, Florida
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not as complicated as it sounds. Forward all requests coming to port 80 to the single IP of the web server box. Use name based virtual hosting. The apache server will read the 'Host' http header sent by the client and serve up whichever site config matches that name. So if you have the correct ServerName directive, it will work just fine.

    Note that SSL enabled sites require their own IP.

    Hope this helps.
    Larry Kagan
    Lead Web Application Developer
    Superiocity, Inc.

  3. #3
    SitePoint Addict mmanders's Avatar
    Join Date
    Jul 2006
    Location
    Edinburgh, Scotland
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If my external ip address is say 123.456.789.123, then a visitor will get directed to 192.168.0.10:80... I already have name based virtual servers set up, say test1.dev and test2.dev both listening on 192.168.0.10:80. If an external visitor requests 123.456.789.123 I don't see how this can possible be translated to test1.dev or test2.dev. - the visitor can't specify which site they want, all they can specify is ip - hence my thought that forwarding to differnt ips on different ports...?

  4. #4
    SitePoint Enthusiast lkagan's Avatar
    Join Date
    Sep 2007
    Location
    Boca Raton, Florida
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry. I thought you had purchased a domain name for your IP. That would have made things much easier. You could simply add sub-domains as needed for free.

    If your friends are techies, you could have them add test1.dev and test2.dev to their etc/hosts file (in both *nix and windows) and have them both point to your single IP (123.456.789.123). Then any browser requests will be made to the one IP but still still send different HTTP Host headers which Apache will see and serve up the correct site.

    Are we on the same page now?
    Larry Kagan
    Lead Web Application Developer
    Superiocity, Inc.

  5. #5
    SitePoint Addict mmanders's Avatar
    Join Date
    Jul 2006
    Location
    Edinburgh, Scotland
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We're on the same page! I have hosting on Hostgator, but I also want to test things on my server that a few people could look at without putting it on my main hosting. I think I'll have to use ip-based hosting for non-techies, i.e. a different port on 123.456.789.123, and each port directs to a certain ip or port on the web server. Cheers!

  6. #6
    SitePoint Enthusiast lkagan's Avatar
    Join Date
    Sep 2007
    Location
    Boca Raton, Florida
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Max, you can still host from your house as well as your service provider. You own the domain name maxmanders.co.uk, which means you can add sub-domains for free and point them to the IP at your house. Most providers provide some control panel to do this. You could create test1.maxmanders.co.uk and test2.maxmanders.co.uk and point them to your home IP. Then all will work like a charm.
    Larry Kagan
    Lead Web Application Developer
    Superiocity, Inc.

  7. #7
    SitePoint Addict mmanders's Avatar
    Join Date
    Jul 2006
    Location
    Edinburgh, Scotland
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's a great idea! I'll look into it...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •