Results 1 to 4 of 4

Thread: Apache2 redirect when no domain

  1. #1
    Join Date
    Oct 2011
    Beans
    11

    Apache2 redirect when no domain

    I'm using NameVirtualHost to direct a domain to a folder. But now when you go to just the server IP, you get the domains folder and not the default. My second domain(as a test) goes to its folder correctly. I want it so that if someone is trying to view the servers ip, they will get a folder that is chmod'ed to 700 so that they will get forbidden.

    Ubuntu Server 11.10 64Bit
    Latest apache, php5

  2. #2
    Join Date
    Aug 2008
    Location
    Victoria, BC Canada
    Beans
    1,721

    Re: Apache2 redirect when no domain

    are you looking for changing the default folder?

    that is found by default in

    /var/www
    SERVER: Azure datacenters, Hyper-V

  3. #3
    Join Date
    May 2007
    Location
    NY's first capital
    Beans
    2,652
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Apache2 redirect when no domain

    When using NameVirtualHosts Apache will forward non-matching requests to the virtual host that comes first (alpha-numerically).

    If you want to force a different default, change the names of you vhost files so your server with 700 as the root comes first.

    I think the default is actually 000-default. The leading zeros make it come first for non matching hostnames including ip requests.
    Nothing is ever easy, but if it is difficult you must be doing it wrong.

  4. #4
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    11,664
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Apache2 redirect when no domain

    Quote Originally Posted by DoubleD33D View Post
    I want it so that if someone is trying to view the servers ip, they will get a folder that is chmod'ed to 700 so that they will get forbidden.
    By default they get the "It Works!" page that is packaged as /var/www/index.html since /var/www is the DocumentRoot in the 000-default configuration.

    You can't really hide the fact that a web server is listening on port 80 just by returning a Forbidden. The remote client will still know the port is open and a server listening there. Just install nmap and run it against your server to see.

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
  •