Hi!
I’m having a problem with my subdomain. First, I use apache and my main domain is www.wasd.pt which uses WordPress. And now i’m trying to create a subdomain that will host a nodejs server in another port (3000).

I’ve created a A record via Digital Ocean networking panel. I’m looking for quickie.wasd.pt

Added new virtual host on 000-default.conf and this is my actual file:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog /var/www/html/error.log
        CustomLog /var/www/html/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =wasd.pt [OR]
RewriteCond %{SERVER_NAME} =www.wasd.pt
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin webmaster@example.com
    ServerName quickie.wasd.pt

    DocumentRoot /var/www/html/quickie
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/html/quickie/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride all
        Order allow,deny
        allow from all
    </Directory>

    ErrorLog /var/www/html/error-quickie.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/www/html/access-quickie.log combined
    # sub:
    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPass / http://wasd.pt:3000/
    ProxyPassReverse / http://wasd.pt:3000/
</VirtualHost>

what intrigues me the most is when i use curl to my subdomain it responds with the html code i’m looking for. Meaning that nodejs is running and working.

What do I need to change more so that the subdomains works?

thanks for you help!
IvoPereira

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hi @ivobastospereir,

First I’ll recommend separating your Apache configurations for each domain into separate virtual host files. If you are not sure how to do this, check this out

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04

The second thing I’m seeing is that you are trying to reach http://wasd.pt:3000/. I tried to open it up however was unable to. Maybe you’ll need to allow connections on port 3000. Another thing would be instead of using wasd.pt:3000, you can try using localhost:3000 or 127.0.0.1:3000 and not the main domain.

Regards,
KFSys

by Lisa Tagliaferri
This tutorial will guide you through setting up multiple domains and websites using Apache virtual hosts on an Ubuntu 18.04 server. During this process, you’ll learn how to serve different content to different visitors depending on which domains they are requesting.
  • Hi @KFSys, tried to change wasd.pt:3000 to your suggestions, but none of them work. I want to redirect quickie.wasd.pt to port 3000, but it seems there is something always redirecting me to main domain. Already looked at .htaccess, but the problem doesn’t seem to be from there.

Can you confirm if created separate configuration files for your websites or are they still in the same file? Can you please separate them just so that it’s more clear going forward?

Additionally, I did understand you want to redirect quickie.wasd.pt
to port 3000 but from your last comment it seems like you want to redirect http://quickie.wasd.pt to https//quickie.wasd.pt:3000 rather than http://wasd.pt:3000/ can you confirm to where you want to redirect the subdomain?

  • Oh, I just opened the subdomain quickie.wasd.pt, and I can see there is some content working there. Did you manage to solve the configuration issue?

    If so, can you confirm what it was so that if other people find it, they can see the solution?

    Regards,
    KFSys