How to configure only sub-domain in droplet.

March 23, 2018 327 views
DNS Apache Caching Initial Server Setup CentOS

I need help in configuring DNS to load test websites on subdomains. I get 403 forbidden error when I access the subdomain.

Let me brief about my requirement:

I have a number of domains for which websites are currently up and running at my other host a2hosting. Each of these domains have their email accounts. And for each domain, I have multiple subdomains. On some subdomains we have deployed operation support applications and some subdomains we use to test website changes before deploying it to production.

My expectation:

I want to do the migration to digital ocean droplet in phases with one domain at a time. At the moment we are looking to test the digitalocean droplet for performance of Magento 2.2.2 based website already running for one of the domains "www.abcdef.com" at a2hosting server.

As of now, I do not want to touch the main domain as it is in production. What I want is to point one of the subdomains "dev.abcdef.com" to this droplet so that we can test the performance of our production code in DigitalOcean.

Please note that, this droplet will be used not only for this domain abcdef.com and it's single subdomain "dev.abcdef.com" but also to host a number of websites corresponding to my other domains and also for their respective subdomains in coming days. If the performance of our Magento 2.2.2 based website in this current testing goes well, then we may go for more droplets with higher configurations.

Note that, since I plan to use Varnish cache so I have set varnish at port 80 and the Apache server at 8080. Varnish and Apache, both are running on same droplet.

What I have done till now to achieve it:

  1. I have configured a firewall for my droplet to accept all TCP connection on port 80 and 8080. Please help me know, if this is right considering the fact that I want to use Varnish for this Magento 2.2.2 based website but I may not use varnish for every website. Some other websites that I will later host on this droplet may be based on other technologies and varnish may not be required for each of them.

  2. The domain abcdef.com is registered with bigrock and the corresponding website is currently hosted at a2hosting. So the Name Servers at bigrock currently points at a2hosting. I already have a sub-domain with name "dev.abcdef.com" at a2hosting which we use to test website changes. To test DigitalOcean droplet, I have changed the A records for the sub-domain "dev.abcdef.com" and "www.dev.abcdef.com" at a2hosting to point to the IP address (159.65.144.102) of droplet at DigitalOcean. I have not created any A records at domain registrar because the name servers configuration at domain registrar level already points to a2hosting IP address. So HTTP requests from user goes to my domain registrar, from there it goes to a2hosting and then from there I route request for subdomain dev.abcdef.com to droplet at Digital Ocean.

  3. I have configured domain and DNS at droplet as below:

    Created a domain "abcdef.com" under Networking section.
    Following are my DNS records for this domain:

Type Hostname Value TTL (seconds)
A dev.abcdef.com directs to 159.65.144.102 3600
NS abcdef .com directs to ns1.digitalocean.com. 1800
NS abcdef .com directs to ns2.digitalocean.com. 1800
NS abcdef .com directs to ns3.digitalocean.com. 1800
  1. I am using Webmin to configure Virtual Hosts Following is my Virtual Host Settings in httpd.conf file.

<VirtualHost *>
DocumentRoot "/home/myadmin/dev.abcdef.com"
ServerName dev.abcdef.com
<Directory "/home/myadmin/dev.abcdef.com">
allow from all
Options None
Require all granted
</Directory>
ServerAlias www.dev.abcdef.com
</VirtualHost>

Problem Faced:

  1. I get 403 Forbidden error when I access the subdomain in url:
  2. The ping command to this subdomain results in timeout error as follows:

ping dev.abcdef.com

Pinging dev.abcdef.com [159.65.144.102] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.

Ping statistics for 159.65.144.102: Packets: Sent = 3, Received = 0, Lost = 3 (100% loss)

  1. The tracert command also gives timeout error as shown following:

tracert dev.abcdef.com

Tracing route to dev.abcdef.com [159.65.144.102]
over a maximum of 30 hops:

1 4 ms 2 ms 1 ms Tenda.Home [192.168.1.1]
2 4 ms 8 ms 7 ms 10.0.0.1
3 3 ms 2 ms 2 ms pacenet.36.0.101.in-addr.arpa [101.0.36.1]
4 111 ms 114 ms 108 ms dsl-ncr-dynamic-105.124.16.125.airtelbroadband.in [125.16.124.105]
5 141 ms 116 ms 98 ms 182.79.203.229
6 132 ms 158 ms 161 ms 202.56.198.58
7 145 ms 137 ms 103 ms 138.197.249.23
8 * * * Request timed out.


I hope I could explain my problem to a satisfactory level. I have also raised a ticket with all these details for this issue but you can make out if I have to explain it again here on forum to get a solution, then how things would be there...

Can someone help me achieve my this simple requirement as explained above. I will be grateful to that helping hand!

Thanks
Devanshu

3 comments
  • I'd be happy to help.

    Looks like a networking issue. is "abcdef.com" your actual domain that you're working with?

    Also, the reason you may not get a response back by ping or traceroute could be your firewall blocking ICMP packets (you stated that your firewall is allowing TCP to port 80 and 8080, I assume it blocks other ports/protocols).

    Everything you stated as far as configuring the domain looks good. But not knowing the actual domain makes it hard to dig deeper.

    Let me know!

  • @dc250org . Thanks for your reply.
    The actual domain name is paperlicense.com. And subdomain is dev. paperlicense.com.

    You are right in saying that firewall is blocking ping. I have removed firewall and I am able to ping now. For troubleshooting, I can disable firewall for some time, but in long run, I would need to configure it in best way.
    So thats one thing, that I would need help in.

    Secondly, I checked the permissions on folders. It was hinted by technical support in reply to my ticket.

    The structure of folder that I planned to keep is like

    home/sysadmin/public_html
    home/sysadmin/dev.paperlicense.com
    home/sysadmin/staging1.paperlicense.com

    And so on...

    The sysadmin is username. I think, By default, when I created the user sysadmin, the permission on sysadmin folder was 700. And when I tried to access url dev.paperlicense.com in browser, it was giving error of 403 forbidden error on folder '/' permission.
    I changed permissions on sysadmin folder to 755 and it started giving error on index.html. I have kept a simple index.html indide dev.paperlicense.com folder with permission 644.

    If you access dev.paperlicense.com, you would find this very same error.

    Thanks
    Devanshu

  • @logicallimit Awesome, glad you resolved the pinging issue. Under normal operations, you don't really need to be able to ping an IP address, but it does help for testing purposes.

    I would recommend editing your firewall rules to allow incoming TCP port 80 & port 8080 AND also allow incoming ICMP packets.

    Regarding the file permissions, looks like you're making progress.
    Try changing the permissions of the index.html file to 755 and see if http://dev.paperlicense.com/ loads for you then.

2 Answers

@AdrianStOnge . I have set the permission of index.html to 0777 also and tried to load the page, but the same error still occurs.

The user group and username that currently shows in ownership details is sysadmin:sysadmin.

This is for sure some permission related issue. Has it got anything to do with the apache user permission with which server is running or something else. If yes, then what changes I would need to do to make it load index. Html.

Ok. So the problem is solved. Here is how I resolved it.

Problem 1: Ping not working.
Temporary Solution: Remove all firewalls applied on the droplet. But remember to put it back. When I removed firewall, I was able to ping. Try solution recommended by @AdrianStOnge .

Problem 2: 403 permission error on /
Solution: Set 755 permission on folder with name of user. In my case it was "sysadmin".

Problem 3: After resolving problem 2, I started getting permission error on /index.html
You don't have permission to access /index.html on this server.
Solution: I let the permission of index.html remain at 644.
Run the command "setsebool -P httpdreaduser_content on" as root user or a user with proper rights.

I got solution for Problem 3 from URL: Solution link

The moment I ran this command, my sub-domain was accessible!

Have another answer? Share your knowledge.