Apache configuration to run Node.js applications on a Virtual Host
- 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 [email protected] | |
| 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 [email protected] | |
| ServerName website.com | |
| ServerAlias www.website.com | |
| Options -Indexes | |
| ProxyRequests on | |
| ProxyPass / http://localhost:5000/ | |
| ProxyPassReverse / http://localhost:5000/ | |
| </VirtualHost> |