Vamos a configurar 3 sitios:
- intranet.eldominio.es, en el directorio /var/www/intranet, interfaz IP1 y puerto 80.
- publico.eldominio.es, en el directorio /var/www/publico, interfaz IP2 y puerto 80 (HTTP)
- privado.eldominio.es, en el directorio
/var/www/privado, interfaz IP2 y puerto 80 (HTTP) redireccionado al
443 (HTTPS)
Este sitio tendrá una carpeta privada con acceso restringido.
Configuración
de 2 interfaces:
1ª -
2ª -
Encendemos
el servidor debian.
# rm
/etc/udev/rules.d/70-persistem-net.rules
# reboot
#
nano /etc/network/interfaces
#
This file describes the network interfaces available on your system
#
and how to activate them. For more information, see interfaces(5).
#
The loopback network interface
auto
lo eth0 eth1
iface
lo inet loopback
#
The primary network interface
allow-hotplug
eth0
allow-hotplug
eth1
iface
eth0 inet dhcp
iface
eth1 inet dhcp
#
service networking restart
#
ifconfig -a
#
apt-get install apache2
#
netstat -putan|grep apache
#
ps -aux|grep apache
Creo las carpetas WEBs:
# cd /var/www
# mkdir intranet publico privado
# cp index.html intranet/
# cp index.html publico/
# cp index.html privado/
# cd privado/
# mkdir apuntes
# cd /etc/apache2/
#
nano ports.conf
NameVirtualHost
192.168.56.101:80
NameVirtualHost
192.168.1.62:80
Listen 80
Creo los sitios:
# cd sites-available/
#
cp default intranet
#
cp default publico
# cp default privado
# nano intranet
ServerAdmin mariujesus@hotmail.com
ServerName intranet.eldominio.es
DocumentRoot /var/www/intranet
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks
MultiViews
AllowOverride None
Order allow,deny
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews
+SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog
${APACHE_LOG_DIR}/error_intranet.log
# Possible values include: debug, info,
notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog
${APACHE_LOG_DIR}/access_intranet.log combined
#
nano publico
ServerAdmin mariujesus@hotmail.com
ServerName publico.eldominio.es
DocumentRoot /var/www/publico
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks
MultiViews
AllowOverride None
Order allow,deny
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews
+SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog
${APACHE_LOG_DIR}/error_publico.log
# Possible values include: debug, info,
notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access_publico.log
combined
#
nano privado
ServerAdmin mariujesus@hotmail.com
ServerName privado.eldominio.es
DocumentRoot /var/www/privado
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks
MultiViews
AllowOverride None
Order allow,deny
allow from all
AllowOverride All
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews
+SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info,
notice, warn, error, crit,
#
alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log
combined
# cp default-ssl privado-ssl
# nano privado-ssl
ServerAdmin
mariujesus@hotmail.com
DocumentRoot /var/www/privado
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks
MultiViews
AllowOverride None
Order allow,deny
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews
+SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog
${APACHE_LOG_DIR}/error_privado.log
# Possible values include: debug, info,
notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog
${APACHE_LOG_DIR}/ssl_access_privado.log combined
Activo los sitios:
# a2ensite intranet
# a2ensite publico
# a2ensite privado
# a2ensite privado-ssl
Activo el modulo seguro y lo configuro:
#
a2enmod ssl
#
a2enmod rewrite
# nano /var/www/privado/.htaccess
ReWriteEngine On
ReWriteCond %{HTTPS} off
ReWriteRule (.*) https://%{HTTP_POST}%{REQUEST_URI}
Activo el modulo de autentificación básica y configuro:
# a2enmod auth_basic
# htpasswd -c /etc/apache2/usuarios alum1
alum1
/ alum1
# htpasswd -c /etc/apache2/usuarios alum2
alum2
/ alum2
# nano /var/www/privado/apuntes/.htaccess
AuthType Basic
AuthName "ALUMNOS MOLONES"
# (Following line optional)
AuthBasicProvider file
AuthUserFile /etc/apache2/usuarios
Require user alum1
Require user alum2
Reiniciamos el servidor
# service apache2 restart
En mi host REAL:
$ sudo nano /etc/hosts
192.168.56.101 intranet.eldominio.es
192.168.1.62 publico.eldominio.es
192.168.1.62 privado.eldominio.es
Verificaciones en el navegador de la máqina Real:
Comentarios
Publicar un comentario
Si te ha gustado, haz un comentario, ..., GRACIAS