Skip to content

Instantly share code, notes, and snippets.

@ivangonzalezg
Last active June 9, 2022 03:32
Show Gist options
  • Save ivangonzalezg/a980e445ca3ce780d702a07d7be86fd5 to your computer and use it in GitHub Desktop.
Save ivangonzalezg/a980e445ca3ce780d702a07d7be86fd5 to your computer and use it in GitHub Desktop.
Run Node.js application on Apache Virtual Host

Run Node.js application on Apache Virtual Host

Apache configuration to run Node.js applications on a Virtual Host

Prerequisites

  • Enable mod_proxy and mod_proxy_http:
sudo a2enmod proxy
sudo a2enmod proxy_http
  • For SSL enable ssl:
sudo a2enmod ssl
# For https
<VirtualHost *:443>
ServerAdmin admin@mail.com
ServerName website.com
ServerAlias www.website.com
Options -Indexes
SSLProxyEngine On
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
ProxyPreserveHost On
SSLEngine on
SSLCertificateKeyFile /etc/letsencrypt/live/website.com/privkey.pem
SSLCertificateFile /etc/letsencrypt/live/website.com/cert.pem
SSLCertificateChainFile /etc/letsencrypt/live/website.com/fullchain.pem
</VirtualHost>
# For http
<VirtualHost *:80>
ServerAdmin admin@mail.com
ServerName website.com
ServerAlias www.website.com
Options -Indexes
ProxyRequests on
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment