How to add a subdomain on a different droplet/server?

July 26, 2019 277 views
DigitalOcean

I have 2 servers on which one have wordpress site on root domain “example.com” and i want to open a discourse forum on other server on my subdomain “forum.example.com”. And my root domain is using cloudlflare.

So when i tried to add a dns of forum and pointed it to the new server, it still shows nothing. I dont know why , i know this is somewhat off topic. But please i am trying to figure this out from couple of weeks.

When i visit the forum.example.com, it shows me the cloudflare page but says the host in not working. I also added the subdomain in my digitalocean panel still nothing

Please help!!

1 Answer

Hi,

Can you confirm if you’ve followed these steps here in:

  1. Login to Cloudflare
  2. Use the drop-down menu in the upper left of your screen and click your domain that you want to install the subdomain on.
  3. Click the DNS icon at the top of the screen.
  4. Select A using the drop-down options
  5. Add the subdomain in NAME
  6. Add the IP address of your droplet in the box labeled IPv4 Address.

If you’ve followed those steps note that it might take a while for the DNS cache to clear over the Globe.

Hope that this helps!
Bobby

  • Yes, i’ve followed all the steps, and even added it in my digitalocean account in the root domain

    However, i’ve waited for 1 hr and it still shows the cloudflare screen

    Error 521 Ray ID: 4fc6ec4fxxxxxx • 2019-07-26 14:04:30 UTC
    Web server is down

  • I tried to visit the subdomain now… and this is what i got -

    Retry for live version :

    This page (https://forum.example.com/finish-installation/confirm-email) is currently offline. However, because the site uses Cloudflare’s Always Online™ technology you can continue to surf a snapshot of the site. We will keep checking in the background and, as soon as the site comes back, you will automatically be served the live version. Always Online™ is powered by Cloudflare | Hide this Alert

    • Sometimes it could take from 1 to 72 hours for the DNS cache to clear over the Globe. Can you try in a few hours and let me know how it goes?

      Also just make sure that the A record for your subdomain name is pointing correctly to the droplet’s IP address.

      Regards,
      Bobby

      • Disable Cloudflare (orange cloud), then DNS will appear quicker!

      • Thankyou man, you the best!!
        I had to wait for 15 hours to get it working!!

        • No problem at all! I’m happy to hear that it is all working now!

          Regards,
          Bobby

          • Hi @Cybil

            I can see that someone already replied to your question. Happy to see that you’ve got it sorted!

            Regards,
            Bobby

          • I’ve got one more issue, can you please guide me through this

            So I tried htaccess to nginx conf converter.

            This is htaccess code

            RewriteEngine On
            
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME}.php -f
            RewriteRule ^(.*)$ $1.php
            
            RewriteRule ^([a-zA-Z0-9\-\_]+)$ index.php?profile=$1 [NC]
            
            
            # Return 404 if original request is .php
            RewriteCond %{THE_REQUEST} "^[^ ]* .*?\.php[? ].*$"
            RewriteRule .* - [L,R=404]
            
            ErrorDocument 404 http://localhost/folder/404
            
            

            Nginx conf code

            # nginx configuration
            
            error_page 404 http://localhost/folder/404;
            
            location / {
              if (!-e $request_filename){
                rewrite ^(.*)$ /$1.php;
              }
              rewrite ^/([a-zA-Z0-9\-\_]+)$ /index.php?profile=$1;
            }
            

            Everything seems to work fine but this line doesn’t works

            rewrite ^/([a-zA-Z0-9\-\_]+)$ /index.php?profile=$1;
            
            

            It is for clean url, but it always shows 404 for that.Please help me out with this

          • Hi @Cybil

            The rewrite rule looks correct, what is the CMS that you are using? Maybe you need to add some extra rules.

            Regards,
            Bobby

          • Hey @bobbyiliev
            Im using NO CMS, its a php site, so do you have any idea what rules should I apply?

          • Hi @Cybil

            This would really depend on your PHP code then. For example, I thin that waht the current rewrite rule that you have does is it forwards any request that comes in, to index.php?profile=.

            For example if you visit yourdomain.com/contact, this would be forwarded to yourdomain.com/index.php?profile=contact.

            Regards,
            Bobby

          • I would recommend also to take a look at this tool here that would help you generate the correct Nginx config for your exact needs:

            https://nginxconfig.io/

Have another answer? Share your knowledge.