Mod Proxy
De wikiGite
Révision datée du 8 juillet 2011 à 09:20 par Nicolas (discussion | contributions) (→Création d'un virtual host sur le proxy)
Sommaire
Principe de fonctionnement en mode Reverse-Proxy
http://httpd.apache.org/docs/2.3/mod/mod_proxy.html
L'utilisation d'Apache mod_proxy (reverse-proxy) permet aux utilisateurs externes d'accéder à un serveur Web interne (dans un LAN derrière un pare-feu) via un serveur proxy (situé en DMZ).
- A creuser :
- Possibilité d'utiliser un tunnel sécurisé (SSL) entre le proxy et le ou les serveur(s) en interne.
- Load_balancing entre plusieurs serveurs
Pré-Requis
- Un serveur situé dans la DMZ avec apache2
- Le serveur Web situé dans le réseau local avec apache2 et un vhost accessible
- Dans le pare-feu, le port 80 (par exemple) doit être autorisé entre le proxy et le serveur Web interne
Activation du module mod_proxy sur le proxy
a2enmod proxy
/etc/init.d/apache2 restart
Création d'un virtual host <nom_du_vhost> sur le proxy
Créer le fichier <nom_du_vhost> dans /etc/apache2/sites-available/ avec le contenu suivant (où ProxyPass pointe vers un vhost du serveur Web local) :
<VirtualHost *:80>
ServerName proxy.domaine.fr
<Location />
ProxyPass http://local.domaine.fr/
</Location>
</VirtualHost>
a2ensite <nom_du_vhost>
/etc/init.d/apache2 restart
# owned by VirtualHost NameVirtualHost 10.0.0.42:80
# FrontPage needs the following four things to be here # otherwise all the vhosts need to go in httpd.conf, which could # get very large since there could be thousands of vhosts ServerRoot /etc/httpd
<VirtualHost 10.0.0.42:80>
<Location />
ProxyPass http://testproxy.systea.fr/
</Location>
ServerName proxy.systea.fr
ServerAdmin admin
#DocumentRoot /home/.sites/28/site1/web
#ErrorDocument 401 /error/401-authorization.html
#ErrorDocument 403 /error/403-forbidden.html
#ErrorDocument 404 /error/404-file-not-found.html
#ErrorDocument 500 /error/500-internal-server-error.html
#RewriteEngine on
#RewriteCond %{HTTP_HOST} !^10.0.0.42(:80)?$
#RewriteCond %{HTTP_HOST} !^proxy.systea.fr(:80)?$ [NC]
#RewriteRule ^/(.*) http://proxy.systea.fr/$1 [L,R=301] #RewriteOptions inherit #AliasMatch ^/~([^/]+)(/(.*))? /home/.sites/28/site1/users/$1/web/$3 #Include /etc/httpd/conf/vhosts/site1.include # BEGIN WebScripting SECTION. DO NOT EDIT MARKS OR IN BETWEEN. # END WebScripting SECTION. DO NOT EDIT MARKS OR IN BETWEEN. # BEGIN PHP SECTION. DO NOT EDIT MARKS OR IN BETWEEN. # END PHP SECTION. DO NOT EDIT MARKS OR IN BETWEEN. </VirtualHost> # end of VirtualHost owned section

