Skip to content

Instantly share code, notes, and snippets.

@nim4n136
Last active December 29, 2020 05:56
Show Gist options
  • Save nim4n136/dae5f7ad3dcdc1a9d344210387a2c79e to your computer and use it in GitHub Desktop.
Save nim4n136/dae5f7ad3dcdc1a9d344210387a2c79e to your computer and use it in GitHub Desktop.
Nodejs revese proxy path apache

1. Add module proxy

Edit file config httpd

sudo nano /etc/httpd/conf/httpd.conf

Add this code to config httpd

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

2. Edit file domain

Edit your config file domain example

sudo nano /etc/httpd/conf.d/example.com.conf

Example your nodejs running in port 3000, just add this code inside tag Virtualhost

<VirtualHost *:80>
  ...
  ProxyRequests On
  ProxyPass /nodeapp http://localhost:3000/
  ProxyPassReverse /nodeapp http://localhost:3000/
  ...
</VirtualHost>

3. Restart apache

sudo systemclt restart httpd

4. Open your nodejs application in browser http://example.com/nodeapp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment