Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subdomain and reverse proxy configuration #164

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 32 additions & 2 deletions sciblog.conf
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@

</VirtualHost>


<IfModule mod_ssl.c>
<VirtualHost *:443>
# Enable HTTP2
Expand All @@ -96,7 +97,6 @@
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem


# Set wsgi
WSGIPassAuthorization On
WSGIApplicationGroup %{GLOBAL}
Expand Down Expand Up @@ -143,8 +143,38 @@
RewriteRule ^(.*)$ https://example.com$1 [R=301]

</VirtualHost>
</IfModule>

# Redirect another web as a reverse proxy
<VirtualHost *:443>
# Server name
# Make sure that there are DNS records (A or AAAA) for blog.example.com
ServerName blog.example.com

# SLL directives and certificates
# Create a new certificate with: $ certbot certonly --apache -d blog.example.com
SSLEngine On
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/blog.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/blog.example.com/privkey.pem

# Proxy configuration for blog.example.com
SSLProxyEngine On
ProxyPreserveHost On # The original host header from the client's request is forwarded to the proxied server
ProxyPass "/" "https://username.substack.com/"
ProxyPassReverse "/" "https://username.substack.com/"

# Rewrite URLs to preserve blog.example.com in the browser address bar
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog\.example\.com$ [NC]
RewriteRule ^/(.*)$ "https://username.substack.com/$1" [P,L]

# Log files
ErrorLog /var/log/apache2/reverse_proxy.error.log
CustomLog /var/log/apache2/reverse_proxy.access.log combined

</VirtualHost>

</IfModule>


# Cache control headers
Expand Down