Results 1 to 6 of 6

Thread: localhost virtual server ignored unless I edit /etc/hosts. what's wrong?

  1. #1
    Join Date
    Jul 2006
    Location
    Los Angeles
    Beans
    1,310
    Distro
    Ubuntu 10.10 Maverick Meerkat

    localhost virtual server ignored unless I edit /etc/hosts. what's wrong?

    I need to test a couple of websites locally, but only sometimes. The rest of the time I want to access them normally out on the web. I use a2ensite and a2dissite to enable and disable. But unless I also manually add a line in /etc/hosts, apache keeps serving the non-local version. That doesn't seem right. Here are the details:

    I've made an entry in /etc/apache2/sites-available/molvray.com. I've made a link to it in /etc/apache2/sites-enabled. I've used sudo a2ensite molvray.com to enable it. I then reload apache2. When I go to the url in the browser, it gives me the web version, not the local version.

    When I add the red line to /etc/hosts, then it gives me the local version:
    Code:
    127.0.0.1	localhost
    127.0.1.1	snowy
    127.0.2.2   www.molvray.com  molvray.com
    When I want to return to the normal, web version of molvray.com, I have to manually comment that line out. Running sudo a2dissite molvray.com and reloading apache is not enough.

    That seems like a bad kludge. I must be doing something wrong, but I can't figure out what it is.

  2. #2
    Join Date
    Mar 2006
    Location
    Kitakyushu Japan
    Beans
    9,362
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: localhost virtual server ignored unless I edit /etc/hosts. what's wrong?

    Nothing's wrong. You have no DNS in place that points to your local version, so your router just sends the request normally. The way to fix this is either to edit /etc/hosts as you've done, or add a local DNS server.

  3. #3
    Join Date
    Jul 2006
    Location
    Los Angeles
    Beans
    1,310
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: localhost virtual server ignored unless I edit /etc/hosts. what's wrong?

    Thanks! I'm off to look up how to add a local DNS server. I'll be back once I'm hopelessly confused.

  4. #4
    Join Date
    Jan 2006
    Location
    Not heaven... Iowa
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: localhost virtual server ignored unless I edit /etc/hosts. what's wrong?

    DNSMasq is supposed to be a DNS/DHCP server. I haven't tried installing/configuring it, but it was on a dial-up router/firewall I had.
    Linux User #415691 Ubuntu User #8629
    Iowa Team (LoCo): [Wiki] [Launchpad]
    IRC channel: #ubuntu-us-ia on irc.freenode.net

  5. #5
    Join Date
    Mar 2006
    Location
    Kitakyushu Japan
    Beans
    9,362
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: localhost virtual server ignored unless I edit /etc/hosts. what's wrong?

    Quote Originally Posted by Iowan View Post
    DNSMasq is supposed to be a DNS/DHCP server. I haven't tried installing/configuring it, but it was on a dial-up router/firewall I had.
    Yeah ... painfully simple actually. Just install dnsmasq, and edit /etc/hosts to include the host names on your LAN. But because of this, the DNS server (DNSmasq or otherwise) shouldn't be on a portable computer. It needs to be on a computer that will be dedicated to the LAN because (at least with dnsmasq and most other DNS servers) in order to have a properly configured DNS server, you will need to edit /etc/hosts anyway.

    So if your only option for a DNS server is to have it locally on your portable computer, you're probably better off just sticking with the manual /etc/hosts edit as needed. Otherwise, you're adding overhead without adding functionality.

  6. #6
    Join Date
    Jul 2006
    Location
    Los Angeles
    Beans
    1,310
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: localhost virtual server ignored unless I edit /etc/hosts. what's wrong?

    Thanks for the tips, folks. I'm going to have a look at DNSmasq. I have an HPMediavault that's permanently attached to the LAN and sounds exactly suited to this sort of thing.

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
  •