Node application redirect to subdomain using virtual hosts

237 Views Asked by At

I'm trying to create a redirect for my nodejs app running a port 5001 to a subdomain and while I browse my nodejs app, I'm trying to keep the subdomain url.

I'm using Debian 8 and the latest Apache version.

I have the following setup:

  • A node app running on server at http://example.com:5001
  • A redirect in apache config

    <VirtualHost *:80>
        ServerName subdomain.example.com
        ServerAlias  subdomain.example.com
        Redirect / http://exemple.com:5001/
    </VirtualHost>
    

This works fine but the url switches

On my other server using Debian 7, I have the following setup :

<VirtualHost *:80>
    ServerName subdomain.example.com
    ProxyPreserveHost On
    ProxyPass / http://example.com:5001/
    ProxyPassReverse / http://example.com:5001/
</VirtualHost>

When I try using the same method on my new server, apache won't restart after changing the virtual host.

What am I doing wrong ?

Thanks

0

There are 0 best solutions below