This will be the 3rd time I’ve typed this as DO just throws it in the garbage after I submit.
I have a droplet that was installed with the wordpress image. I have installed nodejs on the droplet and now I’m running an nodejs websocket server from /var/www/server/. I am hosting the client at /var/www/html/client/ but it will not connect to the websocket server.
After 10+ hours of searching, I think I’ve narrowed it down to something to do with the apache http-proxy but every configuration I’ve tried in the /sites-available/000-default.conf file have failed.
What am I doing wrong? Can somone point me in the correct direction? Thank you.
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!
Accepted Answer
Hi @hidinglapisclam,
You’ll need to configure a Reverse Proxy for your NodeJS server as it listens on a specific port. Usually, when talking about Reverse Proxies, Nginx is the go to WebSerivce. There is even a tutorial on how to add NodeJS with Reverse Proxy to your Droplet here;
If you however whish to use Apache, then your apache config should look something like this:
- <VirtualHost *:80>
- ServerName your-server-ip
-
- ProxyRequests Off
- ProxyPreserveHost On
- ProxyVia Full
-
- <Proxy *>
- Require all granted
- </Proxy>
-
- ProxyPass / http://127.0.0.1:8000/
- ProxyPassReverse / http://127.0.0.1:8000/
- </VirtualHost>
Where the ProxyPass would have your localhost IP address and the port you’ve selected your NodeJs instance to work. The above would code would be integrated with your website’s Apache config in the /etc/apache2/sites-available/ folder.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.