5

I am using VirtualHosts to allow access to various domains and subdomians of my site on the same Apache server. Along the lines of:

<VirtualHost *:80>
    DocumentRoot /var/www/site
    ServerName example.com
</VirtualHost>

I want to have a specific subdomain pointing to a NodeJS server on the same server. I know I could use ProxyPass to forward to a different server, is there a similar way to do this with the same machine?

I assume I would have the Node server running on a port other than 80.

14

Lets assume,

Node.js running on http://localhost:8000

<VirtualHost node.example.com:80>   
    ServerName node.example.com
    # with optional timeout settings  
    ProxyPass / http://localhost:8000/ connectiontimeout=5 timeout=30
</VirtualHost>

I hope that helps

3
  • 1
    Thanks a lot, I didn't realise that ProxyPass could work for localhost. Derp! – JJJollyjim Apr 10 '13 at 8:10
  • 2
    Are there situations where this configuration also need the ProxyPassReverse directive? – snapfractalpop Sep 14 '17 at 0:05
  • "Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request " why is that appeared once i used your solutions? – gumuruh Jul 4 '20 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.