I am working on having third level domains redirected to a folder using apache proxy.
I am starting from the following code:
<VirtualHost *:80>
ServerName blog.example.com
ErrorLog /var/www/blog.example.com/log/error.log
CustomLog /var/www/blog.example.com/log/requests.log combined
ProxyPass "/" "http://example.com/blog/"
ProxyPassReverse "/" "http://example.com/blog/"
</VirtualHost>
My domain is using letsencrypt to provide ssl so for the domain i have two vhosts. How do I best integrate this proxy configuration in my current configuration so that it works on https?
VHost example.conf
<VirtualHost *:80>
ServerName example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/
<Directory /var/www/html/ >
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
VHost example.com-le-ssl.conf
ServerName example.com
ServerAdmin [email protected]
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorDocument 404 /custom404.html
ErrorDocument 500 /custom500.html
ErrorDocument 502 /custom500.html
ErrorDocument 503 /custom500.html
ErrorDocument 504 /custom500.html
<Files "custom404.html">
<If "-z%{ENV:REDIRECT_STATUS}">
RedirectMatch 404 ^/custom404.html$
</If>
</Files>
<Files "custom500.html">
<If "-z %{ENV:REDIRECT_STATUS}">
RedirectMatch 500 ^/custom500.html$
</If>
</Files>
ProxyPreserveHost On
SSLProxyEngine On
ProxyPass /store https://example.com:4343
ProxyPassReverse /store https://example.com:4343
Include /etc/letsencrypt/options-ssl-apache.conf
SetEnv ENV_TYPE "dev"
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
question from:
https://stackoverflow.com/questions/65917460/third-level-domain-to-folder-with-proxy-using-https 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…