Skip to content

Instantly share code, notes, and snippets.

@fvoska
Last active February 3, 2024 09:04
Show Gist options
  • Save fvoska/4c801ccf005368d8ae91256a361c9b96 to your computer and use it in GitHub Desktop.
Save fvoska/4c801ccf005368d8ae91256a361c9b96 to your computer and use it in GitHub Desktop.
Apache reverse proxy configuration for Node.js with Let's Encrypt SSL/TLS certificate.
a2ensite subdomain.me.com.conf
a2ensite subdomain.me.com.ssl.conf
service apache2 reload
Node.js app listens on 8080 for HTTP. It doesn't need to listen for HTTPS.
In firewall, allow port 8080 only on localhost interface.
Let's encrypt certificate is created for subdomain.me.com and stored in /home/USER/letsencrypt/etc/live/subdomain.me.com
# /etc/apache2/sites-available/subdomain.me.com.conf
<VirtualHost *:80>
ServerName subdomain.me.com
<Location "/">
ProxyPreserveHost On
ProxyPass http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>
# If you want to redirect HTTP to HTTPS, remove <Location> above and add Redirect:
# Redirect permanent / https://subdomain.me.com/
</VirtualHost>
# /etc/apache2/sites-available/subdomain.me.com.ssl.conf
<VirtualHost *:443>
ServerName subdomain.me.com
SSLEngine on
SSLCertificateFile /home/USER/letsencrypt/etc/live/subdomain.me.com/fullchain.pem
SSLCertificateKeyFile /home/USER/letsencrypt/etc/live/subdomain.me.com/privkey.pem
<Location "/">
ProxyPreserveHost On
ProxyPass http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>
</VirtualHost>
@gabrielporfiro
Copy link

tutorial dos deuses? vou testar

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