How to point a port to a subdomain?

October 10, 2015 1.7k views
DNS Miscellaneous Ubuntu

I'm running ubuntu on a digitalocean server, and I have a web app rutting on port 3001. Basically, how my site is currently setup, I have to go to to reach the web app. I'd like to make it use instead. Is there any possible solution for this? I'm new to hosting and subdomains.

Thank you in advance! :)

  • What type of web server are you using with your app?
    You may want to investigate virtual hosts, but let us know, and we can give you more specific advice.

  • @BrookDO I'm using Digital Ocean for my webserver. I have been Googling, but haven't been finding anything, so this "virtual host" you speak of may work (but I don't know what it is unfortunately). Maybe you could point me in the right direction?


  • @BrookDO After a bit more searching, I figured out about virtual hosts.

    I made a CNAME in the DNS so that I have, and setup my virtual host file like this:

    <VirtualHost *:80>
        DocumentRoot /root/app/web
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

    As you can see, the document root isn't under /var/www/mydomain/public_html like normal sites are. I always get a 403 Forbidden when I attempt to access the subdomain. I even tried putting a simlink in the /var/www/mydomain/public_html folder, directing to my app in /root/app/web, but I still get a forbidden error. However, the url "" still goes to the app.

    by Justin Ellingwood
    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 14.04 VPS.
  • Hi,

    Are the permissions correct for the /root/app/web folder?

    sudo chown -R $USER:$USER /root/app/web/
    sudo chown -R $USER:$USER /root/app/web
    sudo chmod -R 755 /root/app/

    Also, in this case, I would remove the "www" from the line


    as the alias will still be

    Also, did the step that included this command

    sudo a2ensite

    work? And when you restarted Apache, did you see any errors?

Be the first one to answer this question.