Last active
May 14, 2020 19:07
-
-
Save maurice-audin/0be8383197908938467e817d368a7a10 to your computer and use it in GitHub Desktop.
Apache basic proxy for DNS migration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# DOMAIN_TLD=yourdomain.example.com | |
# TARGET_IP=192.168.1.2 | |
# cp proxy.DOMAIN_TLD.conf proxy.${DOMAIN_TLD}.conf | |
# sed -i "s/DOMAIN_TLD/${DOMAIN_TLD}/g" proxy.${DOMAIN_TLD}.conf | |
# sed -i "s/TARGET_IP/${DOMAIN_TLD}/g" proxy.${DOMAIN_TLD}.conf | |
# a2ensite proxy.${DOMAIN_TLD}.conf | |
# systemctl reload apache2 | |
# Adapt DOMAIN_TLD and TARGET_IP | |
<VirtualHost *:80> | |
ServerName DOMAIN.TLD | |
<Proxy *> | |
Order allow,deny | |
Allow from all | |
</Proxy> | |
ProxyPreserveHost On | |
ProxyPass / http://TARGET_IP/ | |
ProxyPassReverse / http://TARGET_IP/ | |
ErrorLog /var/log/apache2/proxy.DOMAIN.TLD/error.log | |
CustomLog /var/log/apache2/proxy.DOMAIN.TLD/access.log combined | |
</VirtualHost> | |
<VirtualHost *:443> | |
ServerName DOMAIN.TLD | |
SSLEngine On | |
SSLCertificateFile /etc/acme/DOMAIN.TLD/DOMAIN.TLD.cer | |
SSLCertificateKeyFile /etc/acme/DOMAIN.TLD/DOMAIN.TLD.key | |
SSLCertificateChainFile /etc/acme/DOMAIN.TLD/fullchain.cer | |
<Proxy *> | |
Order allow,deny | |
Allow from all | |
</Proxy> | |
ProxyPreserveHost On | |
SSLProxyEngine On | |
ProxyPass / https://TARGET_IP/ | |
ProxyPassReverse / https://TARGET_IP/ | |
ErrorLog /var/log/apache2/proxy.DOMAIN.TLD/error.log | |
CustomLog /var/log/apache2/proxy.DOMAIN.TLD/access.log combined | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment