Reverse Proxy

Installation sur Ubuntu Server 20.04 LTS

Packages

sudo apt-get install apache2 certbot libapache2-mod-php

Activation modules

sudo a2enmod php7.4 proxy proxy_connect proxy_http proxy_wstunnel rewrite ssl

Prise en compte

sudo systemctl restart apache2

Configuration

<IfModule mod_ssl.c> <VirtualHost *:443> ServerName domaine1.fr ErrorLog ${APACHE_LOG_DIR}/domaine1.error.log CustomLog ${APACHE_LOG_DIR}/domaine1.log combined ProxyPreserveHost On ProxyRequests Off ProxyVia Off ProxyPass / https://xxx.xxx.xxx.xxx:port1/ ProxyPassReverse / https://xxx.xxx.xxx.xxx:port1/ SSLEngine on SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key SSLProxyEngine On SSLProxyCheckPeerCN Off SSLProxyCheckPeerName Off SSLProxyCheckPeerExpire off SSLProxyVerify none </VirtualHost> <VirtualHost *:443> ServerName domaine2.fr ErrorLog ${APACHE_LOG_DIR}/domaine2.error.log CustomLog ${APACHE_LOG_DIR}/domaine2.access.log combined ProxyPreserveHost On ProxyRequests Off ProxyVia Off ProxyPass / https://xxx.xxx.xxx.xxx:port2/ ProxyPassReverse / https://xxx.xxx.xxx.xxx:port2/ RewriteEngine On RewriteCond %{HTTP:Upgrade} =websocket [NC] RewriteRule ^/(.*) wss://xxx.xxx.xxx.xxx:port2/$1 [P,L] SSLEngine on SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key SSLProxyEngine On SSLProxyCheckPeerCN Off SSLProxyCheckPeerName Off SSLProxyCheckPeerExpire off SSLProxyVerify none </VirtualHost>

Haut de page