jueves, 8 de agosto de 2013

Reverse Proxy con Apache 2 en Debian

Instalamos modulo para apache:

# apt-get install libapache2-mod-proxy-html
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common file
  libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libcap2
  libdb4.7 libexpat1 libgcrypt11 libgnutls26 libgpg-error0 libldap-2.4-2
  libmagic1 libpcre3 libsasl2-2 libsasl2-modules libtasn1-3 libxml2
  mime-support openssl perl perl-modules sgml-base ssl-cert xml-core
Suggested packages:
  www-browser apache2-doc apache2-suexec apache2-suexec-custom rng-tools
  gnutls-bin libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql
  libsasl2-modules-gssapi-mit libsasl2-modules-gssapi-heimdal ca-certificates
  perl-doc libterm-readline-gnu-perl libterm-readline-perl-perl make
  sgml-base-doc openssl-blacklist debhelper
The following NEW packages will be installed:
  apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common file
  libapache2-mod-proxy-html libapr1 libaprutil1 libaprutil1-dbd-sqlite3
  libaprutil1-ldap libcap2 libdb4.7 libexpat1 libgcrypt11 libgnutls26
  libgpg-error0 libldap-2.4-2 libmagic1 libpcre3 libsasl2-2 libsasl2-modules
  libtasn1-3 libxml2 mime-support openssl perl perl-modules sgml-base ssl-cert
  xml-core
0 upgraded, 31 newly installed, 0 to remove and 0 not upgraded.
Need to get 14.9 MB of archives.
After this operation, 55.3 MB of additional disk space will be used.
Do you want to continue [Y/n]? Y


Configuramos el httpd con lo siguiente:

# vim /etc/apache2/httpd.conf
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_connect_module /usr/lib/apache2/modules/mod_proxy_connect.so
LoadModule proxy_ftp_module /usr/lib/apache2/modules/mod_proxy_ftp.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
ProxyRequests Off

    Order deny,allow
    Allow from all

ProxyPass /web http://www.mi_web_server.com.ar/
ProxyPassReverse /web http://www.mi_web_server.com.ar/
ProxyPreserveHost On


Reiniciamos apache:


# /etc/init.d/apache2 restart
Restarting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.0.1 for ServerName
 ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.0.1 for ServerName


Para solucionar el warning previo, editamos el archivo de configuración de apache:

# vim /etc/apache2/apache2.conf
ServerName nombre_server


Reiniciamos el apache y vemos que ahora no aparece el warning:

# /etc/init.d/apache2 restart
Restarting web server: apache2 ... waiting .

Fuente: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html


No hay comentarios: