Question

I'm trying to set up my php website so it can communicate to a node.js server that has a chat software on it.

In httpd.conf, I'm supposed to add something like this:

    <VirtualHost *:80>
        ServerAdmin admin@[domain.tld]
        DocumentRoot /var/www/html/[websitedir]
        ServerName [domain.tld]
        ServerAlias [domain.tld] *.[domain.tld]
        Proxypass /chat http://localhost:8000
        ProxyTimeout 310
    </VirtualHost> 

Jus to to clarify, this is supposed to go in my PHP server and the domain.tld should be my node.js server address. right? also,

    ProxyPass /chat http://localhost:8000

should also contain my node.js server instead of localhost. Also, with /chat/ as a ProxyPass parameter, myphpserver.com/chat will redirect to mynodeserver:8000. Am I getting this right?

Thanks.

Was it helpful?

Solution

That will not redirect, it will create a reverse proxy. Effectively, Apache will relay all messages back and forth between your client and your node server.

As a safety precaution, you may want to do this instead:

ProxyPass /chat/ http://localhost:8000/
ProxyPassReverse /chat/ http://localhost:8000/

Not including the trailing slash opens you up to proxy errors on any page that starts with chat... such as /chatrooms being proxied to http://localhost:8000rooms

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top