deb/apache-register-forward-proxy.bash
author Oleksandr Gavenko <gavenkoa@gmail.com>
Thu, 02 May 2024 15:47:37 +0300
changeset 34 68975e7d5237
parent 27 9b0cc94cd960
permissions -rw-r--r--
Recreate Apache settings for Lets Encrypt SSL.

#!/bin/bash

# curl -v google.com --proxy blog.defun.work:8888 --proxy-user proxy:PASS

# sudo a2enmod proxy proxy_http proxy_connect

set -x

# To meet uploading requirements.
apt install rsync

d=forward-proxy
mkdir -p /srv/www/$d
chown user:user /srv/www/$d

cat <<EOF >/etc/apache2/sites-available/$d.conf
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

<VirtualHost $d.defun.work:*>
    ProxyRequests On
    ProxyVia On

    Require ip 46.118

    LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error_forward_proxy.log
    CustomLog ${APACHE_LOG_DIR}/access_forward_proxy.log
</VirtualHost>

<IfModule mod_ssl.c>
  <VirtualHost $d.defun.work:443>
    ProxyRequests On
    ProxyVia On

    Require ip 46.118

    LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error_forward_proxy.log
    CustomLog ${APACHE_LOG_DIR}/access_forward_proxy.log

    SSLCertificateFile /etc/letsencrypt/live/defun.work/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/defun.work/privkey.pem
    Include /srv/www/letsencrypt/apache-ssl-options.conf
  </VirtualHost>
</IfModule>
'EOF'

a2ensite $d
service apache2 reload