Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Apache Subdomains don't go to where they are told to go

  1. #1
    Join Date
    Apr 2009
    Beans
    51

    Apache Subdomains don't go to where they are told to go

    I am using Ubuntu 12.04, and Webmin to set up a web server. The server works just dandy if I create a virtual host and point my domain to the server. I can go to my site just fine by going to domain.com or www.domain.com. What doesn't work, is subdomains.

    I created a new Virtual Host in Webmin to point to subdomain.domain.com on port 80. My DNS zones are set up so subdomain.domain.com points to my IP address, but when I go to subdomain.domain.com, it loads up the site that domain.com (no subdomain) is supposed to be going to, despite the fact that subdomain.domain.com is supposed to be pointing to /home/subdomain/www (existing directory) and domain.com points to /var/www.

    What in the bloody hell am I doing wrong? This is extremely frustrating, because from past experience, I should be done right now. I've done this before on a past version of Ubuntu with Webmin...

    I am extremely tired and frustrated, so I'm sure I've missed something, so if you need more information, just let me know I'll cough it up.

  2. #2
    Join Date
    Oct 2012
    Beans
    182

    Re: Apache Subdomains don't go to where they are told to go

    Quote Originally Posted by Master_Taco View Post
    I am using Ubuntu 12.04, and Webmin to set up a web server. The server works just dandy if I create a virtual host and point my domain to the server. I can go to my site just fine by going to domain.com or www.domain.com. What doesn't work, is subdomains.

    I created a new Virtual Host in Webmin to point to subdomain.domain.com on port 80. My DNS zones are set up so subdomain.domain.com points to my IP address, but when I go to subdomain.domain.com, it loads up the site that domain.com (no subdomain) is supposed to be going to, despite the fact that subdomain.domain.com is supposed to be pointing to /home/subdomain/www (existing directory) and domain.com points to /var/www.

    What in the bloody hell am I doing wrong? This is extremely frustrating, because from past experience, I should be done right now. I've done this before on a past version of Ubuntu with Webmin...

    I am extremely tired and frustrated, so I'm sure I've missed something, so if you need more information, just let me know I'll cough it up.
    make sure you have not defined an alias as *.domain.com in you main domain.com virtual host.

  3. #3
    Join Date
    May 2007
    Location
    NY's first capital
    Beans
    2,868
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Apache Subdomains don't go to where they are told to go

    Please post the output of the following:

    Code:
    ls /etc/apache2/sites-enabled
    Code:
    cat /etc/apache2/ports.conf
    Nothing is ever easy, but if it is difficult you must be doing it wrong.

  4. #4
    Join Date
    Apr 2009
    Beans
    51

    Re: Apache Subdomains don't go to where they are told to go

    Quote Originally Posted by volkswagner View Post
    Please post the output of the following:

    Code:
    ls /etc/apache2/sites-enabled
    Code:
    cat /etc/apache2/ports.conf
    Code:
    Mon Dec 10 09:50:58 CST 2012
    ~
    justin@ubuntu-web-server: pts/1: 17 files b -> ls /etc/apache2/sites-enabled
    webmin.1355111967.conf  webmin.1355112046.conf
    Code:
    Mon Dec 10 09:51:13 CST 2012
    ~
    justin@ubuntu-web-server: pts/1: 18 files b -> cat /etc/apache2/ports.conf
    # If you just change the port or add more ports here, you will likely also
    # have to change the VirtualHost statement in
    # /etc/apache2/sites-enabled/000-default
    # This is also true if you have upgraded from before 2.2.9-3 (i.e. from
    # Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
    # README.Debian.gz
    
    Listen *:80
    
    <IfModule mod_ssl.c>
        # If you add NameVirtualHost *:443 here, you will also have to change
        # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
        # to <VirtualHost *:443>
        # Server Name Indication for SSL named virtual hosts is currently not
        # supported by MSIE on Windows XP.
    Listen *:443
    </IfModule>
    
    <IfModule mod_gnutls.c>
        Listen 443
    </IfModule>

  5. #5
    Join Date
    May 2007
    Location
    NY's first capital
    Beans
    2,868
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Apache Subdomains don't go to where they are told to go

    I really don't like how Webmin handles virtualhosts. You will be having more joy by avoiding webmin to administer apache2.

    With that said lets see if we can get it working.

    What do the vhost files look like?

    Code:
    cat /etc/apache2/sites-available/webmin.1355111967.conf
    Code:
    cat /etc/apache2/sites-available/webmin.1355112046.conf
    Normally port.conf should included the NamedVirtualHost directive, but I have a suspicion webmin adds it to each vhost file.

    ports.conf should have:

    Code:
    NameVirtualHost *:80
    The above should match your vhost file opening tag either *, *:80, or even your ip instead of *, anyway the portion after host needs to match.

    Code:
    <VirtualHost *:80>
    Nothing is ever easy, but if it is difficult you must be doing it wrong.

  6. #6
    Join Date
    Apr 2009
    Beans
    51

    Re: Apache Subdomains don't go to where they are told to go

    Quote Originally Posted by volkswagner View Post
    I really don't like how Webmin handles virtualhosts. You will be having more joy by avoiding webmin to administer apache2.

    With that said lets see if we can get it working.

    What do the vhost files look like?

    Code:
    cat /etc/apache2/sites-available/webmin.1355111967.conf
    Code:
    cat /etc/apache2/sites-available/webmin.1355112046.conf
    Normally port.conf should included the NamedVirtualHost directive, but I have a suspicion webmin adds it to each vhost file.

    ports.conf should have:

    Code:
    NameVirtualHost *:80
    The above should match your vhost file opening tag either *, *:80, or even your ip instead of *, anyway the portion after host needs to match.

    Code:
    <VirtualHost *:80>

    Code:
    Mon Dec 10 09:52:15 CST 2012
    ~
    justin@ubuntu-web-server: pts/1: 18 files b -> cat /etc/apache2/sites-available/webmin.1355111967.conf
    <VirtualHost _default_:80>
    DocumentRoot /var/www
    <Directory "/var/www">
    allow from all
    Options +Indexes
    </Directory>
    </VirtualHost>
    Code:
    Mon Dec 10 19:55:24 CST 2012
    ~
    justin@ubuntu-web-server: pts/1: 18 files b -> cat /etc/apache2/sites-available/webmin.1355112046.conf
    <VirtualHost kyle.thecdrive.com:80>
    DocumentRoot /home/kyle/www
    <Directory "/home/kyle/www">
    allow from all
    Options +Indexes
    </Directory>
    ServerName kyle.thecdrive.com
    </VirtualHost>
    Looks to me like everything is peachy. :\

  7. #7
    Join Date
    May 2007
    Location
    NY's first capital
    Beans
    2,868
    Distro
    Ubuntu 20.04 Focal Fossa

    Re: Apache Subdomains don't go to where they are told to go

    I would add the following directive to ports.conf.

    Code:
    NameVirtualHost *:80
    Then restart apache2.
    Nothing is ever easy, but if it is difficult you must be doing it wrong.

  8. #8
    Join Date
    Nov 2006
    Location
    Belgium
    Beans
    3,025
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Apache Subdomains don't go to where they are told to go

    you need
    Code:
    <VirtualHost *>
        ServerName kyle.thecdrive.com
    
    # + the rest : directory def, etc.
    </VirtualHost>
    It's the ServerName directive that lets apache distinguish between name based vhosts. Without it, a vhost def defaults to the "main" server.



    http://httpd.apache.org/docs/2.2/mod...ml#virtualhost




    and, of course, restart or reload after config changes, as always.

  9. #9
    Join Date
    Apr 2009
    Beans
    51

    Re: Apache Subdomains don't go to where they are told to go

    Quote Originally Posted by koenn View Post
    you need
    Code:
    <VirtualHost *>
        ServerName kyle.thecdrive.com
    
    # + the rest : directory def, etc.
    </VirtualHost>
    It's the ServerName directive that lets apache distinguish between name based vhosts. Without it, a vhost def defaults to the "main" server.



    http://httpd.apache.org/docs/2.2/mod...ml#virtualhost




    and, of course, restart or reload after config changes, as always.
    I don't think I'm understanding what you're trying to say, because to me you're telling me to add the ServerName directive to the kyle.thecdrive.com's vhost, but that already exists. I looked at the link you gave me, and it appears to be set up correctly, the only things it's missing is the Logs and ServerAdmin directives, which as far as I'm aware are non-critical to the functioning of the server, right?

  10. #10
    Join Date
    Apr 2009
    Beans
    51

    Re: Apache Subdomains don't go to where they are told to go

    Quote Originally Posted by volkswagner View Post
    I would add the following directive to ports.conf.

    Code:
    NameVirtualHost *:80
    Then restart apache2.
    Unfortunately, adding that did not do anything at all. I added it under the line "Listen", like this:
    Code:
    Listen *:80
    NameVirtualHost *:80

Page 1 of 2 12 LastLast

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
  •