VestaCP - Redirect subdomain to port on my server

696 views Asked by At

I've been struggling with these for years... then I quit and now I want to do it again.

I have a DigitalOcean doplet with VestaCP installed on it and a few websites/users.

One of those websites is mine (let's name it mycoolapp.com) and I'm using it to display a web page and a web app (Spring Boot)

The app runs on a certain port, lest say 1234 and I wan't to link it to a subdomain on my site.

Here's what I done:

  • Create a CNAME record that points app.mycoolapp.com as an alias of mycoolapp.com

  • Then I try with htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^app.mycoolapp.com $ [NC]
RewriteRule ^(.*)$ http://mycoolapp.com:1234$1 [R=301,L]

but it's not working

  • Also try modifying /home/$USER/conf/web/apache2.conf adding at the end of it:

<VirtualHost *:80>
    ServerName app.mycoolapp.com
    redirect / http://mycoolapp.com:1234/
</VirtualHost>

And still not working.

In both cases, what I see is that whenever I enter app.mycoolapp.com I go to my admin web page (the same page I would see if I paste the droplet IP in my browser). And this is happening ever since I create the CNAME record

0

There are 0 answers