Skip to content

Instantly share code, notes, and snippets.

@bryanmylee
Last active November 10, 2020 03:57
Show Gist options
  • Save bryanmylee/2df50fc6ef9a3c7dbfe8f2d4ff2788fa to your computer and use it in GitHub Desktop.
Save bryanmylee/2df50fc6ef9a3c7dbfe8f2d4ff2788fa to your computer and use it in GitHub Desktop.
Configuring Apache to handle HTTPS and act as a proxy for other services
# If HTTPS is required on any project, this is a simple way
# of encrypting the connection without modifying the project.
# Add these settings to /etc/httpd/conf/httpd.conf
# Redirect HTTP requests to HTTPS and rewrite the URL
Listen 80
<VirtualHost *:80>
ServerName "ryver.life"
ServerAlias "www.ryver.life"
RewriteEngine on
RewriteCond %{SERVER_NAME} =ryver.life [OR]
RewriteCond %{SERVER_NAME} =www.ryver.life
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
# Decrypt the HTTPS connection and proxy it to another port on the machine
<VirtualHost *:443>
ProxyPreserveHost On
ProxyRequests Off
ServerName "ryver.life"
ServerAlias "www.ryver.life"
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/ryver.life/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ryver.life/privkey.pem
SSLCACertificateFile /etc/letsencrypt/live/ryver.life/fullchain.pem
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment