ivcfadmin
By:
ivcfadmin

I can ping my subdomain, but when I browse it, it always load the top domain.

October 1, 2016 338 views
Apache Ubuntu

Followed the instructions in DO on how to setup and my Domain Server.

6 Answers

Common guys can someone help me please.

  • Hello and welcome,
    Without any further informations, we will have hard time helping you. I recommend you post your DNS settings (e.g. list of A, CNAME records, screenshot or ZONE file) and Apache Virtual Host settings?
    Did you setup Apache to use new subdomain?

    The Apache web server is the most popular way to serve web content on the internet. Apache has the ability to serve multiple domains from a single server by using a mechanism called "virtual hosts". If a virtual host is configured correctly for each domain, the web server can correctly route traffic to the appropriate files based on the domain name requested. In this guide, we'll demonstrate how to configure Apache virtual hosts on an Ubuntu 16.04 server.

here is my virtual hosts settings:
<VirtualHost *:80>
ServerAdmin admin@domain.org
DocumentRoot /var/www/lists.domain.org/public_html

    <Directory /var/www/lists.domain.org/public_html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Zone file:
$ORIGIN domain.org.
$TTL 1800
domain.org. IN SOA ns1.digitalocean.com. hostmaster.domain.org. 1475233282 10800 3600 604800 1800
domain.org. 1800 IN NS ns1.digitalocean.com.
domain.org. 1800 IN NS ns2.digitalocean.com.
domain.org. 1800 IN NS ns3.digitalocean.com.
domain.org. 1800 IN A 128.199.118.215
domain.org. 1800 IN MX 1 aspmx.l.google.com.
domain.org. 1800 IN MX 5 alt1.aspmx.l.google.com.
domain.org. 1800 IN MX 5 alt2.aspmx.l.google.com.
domain.org. 1800 IN MX 10 alt3.aspmx.l.google.com.
domain.org. 1800 IN MX 10 alt4.aspmx.l.google.com.

Hi again,
Looks like both ZONE file and Apache VH are problem.

Looking at ZONE file, I can't see record for your subdomain. You can add an CNAME record to make it work.
Login into your DigitalOcean Control Panel
Go to Networking -> Domains, select your domain
Select CNAME option, for name enter name of subdomain (e.g. lists) and for hostname enter @.
@ ensures that CNAME record will be applied to origin domain name (domain.org).
When this step is completed you will see new entry in ZONE file, it it will be like:

lists.domain.org. 1800 IN CNAME domain.org.

Now flush your DNS&Browser cache and try again. Sometimes it takes longer for DNS changes to be propagated.

I can recommend adding ServerName directive to Apache Virtual Host for subdomain:

<VirtualHost *:80>
    ServerAdmin admin@domain.org
    ServerName lists.domain.org
    DocumentRoot /var/www/domain.org/public_html

    <Directory /var/www/lists.domain.org/public_html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Try the following procedure, if problem still persists, we will try to find solution by searching for logs, etc.
But I think this will be enough, we will see. :)

Still the same problem. I added CNAME as instructed:

$ORIGIN domain.org.
$TTL 1800
domain.org. IN SOA ns1.digitalocean.com. hostmaster.domain.org. 1475372848 10800 3600 604800 1800
domain.org. 1800 IN NS ns1.digitalocean.com.
domain.org. 1800 IN NS ns2.digitalocean.com.
domain.org. 1800 IN NS ns3.digitalocean.com.
domain.org. 1800 IN A 128.199.118.215
domain.org. 1800 IN MX 1 aspmx.l.google.com.
domain.org. 1800 IN MX 5 alt1.aspmx.l.google.com.
domain.org. 1800 IN MX 5 alt2.aspmx.l.google.com.
domain.org. 1800 IN MX 10 alt3.aspmx.l.google.com.
domain.org. 1800 IN MX 10 alt4.aspmx.l.google.com.
lists.domain.org. 1800 IN CNAME domain.org.

and made changes to VH:
<VirtualHost *:80>
ServerAdmin admin@domain.org
ServerName lists.domain.org
DocumentRoot /var/www/domain.org/public_html

<Directory /var/www/lists.domain.org/public_html/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

  • If this Virtual Host is in special file, did you enabled it using a2ensite ? And did you restarted apache after changes?

    • sudo systemctl restart apache2

    You can look for logs file.
    There is Error logs, and Access logs, both probably located at /var/log/apache2/ if you didn't changed it.
    You can opet it with

    • nano /var/log/apache2/error.log
    • nano /var/log/apache2/access.log
  • @ivcfadmin , addition to previous comment:
    Also what comes to my mind is NameVirtualHost.
    Follow up the link for it explained, it is from apache docs.

    In your situation, it could look like these:

    NameVirtualHost *:80
    <VirtualHost *:80>
        ServerAdmin admin@domain.org
        ServerName domain.org
        #If you use www
        ServerAlias www.domain.org
        ...
    </VirtualHost>
    <VirtualHost *:80>
        ServerAdmin admin@domain.org
        ServerName lists.domain.org
        ServerAlias lists.domain.org
        DocumentRoot /var/www/domain.org/public_html
    
    <Directory /var/www/lists.domain.org/public_html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    </VirtualHost>
    

    I have also added ServerAlias to lists.domain.org just in case.
    I also had redirection problems on apache, and this somehow helped me :P

It is working now. it took more time than expected for the Domain to propagate.
Thank you all.

Have another answer? Share your knowledge.