Subdomain redirects to main domain - Apache

Hi! I’m having a problem with my subdomain. First, I use apache and my main domain is 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

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

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

RewriteEngine on
RewriteCond %{SERVER_NAME} [OR]
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

<VirtualHost *:80>

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

    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 /
    ProxyPassReverse /

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

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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 to port 3000 but from your last comment it seems like you want to redirect to https// rather than can you confirm to where you want to redirect the subdomain?

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

The second thing I’m seeing is that you are trying to reach 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, you can try using localhost:3000 or and not the main domain.

Regards, KFSys