Escenario: HTTPS en Apache Web Server
Sumario
Introdución
O obxectivo deste escenario é explicar como configurar o servidor web Apache para traballar tanto con http como https:
Implementar un sistema coas seguintes características:
- O servidor servidor web Apache corre nun Linux Ubuntu Server 22.04.
- O servidor web terá un sitio por defecto e dous dominios: www.tenda1.example e www.tenda2.example.
- O acceso ós dous dominios poderá facerse tanto por http coma por https.
- Cada dominio usará o seu propio certificado.
- Os certificados dixitais serán crearanse por nós (certificados autoasinados).
NOTA. Empregaremos o dominio .example seguindo a recomendación da IANA en relación á elaboración de documentación.
Configuración do escenario
A creación e configuración dos equipos a usar no Escenario 5C implica configurar o server (servidor web) e o equipo cliente dende onde visitaremos as páxinas web dos sitios www.tenda1.example e www.tenda2.example. A continuación explícase:
Como crear/configurar o server mediante un script Como configurar a resolución dns do cliente para as probas de funcionamento A configuración do cliente explícase ó final desta páxina.
Configuración do server
Creación automática do escenario
Como primeiro paso hai que levar o arquivo script_esc_5C.tar.gz ó equipo anfitrión dos contedores. Esto dependerá da situación particular de cada un; eu normalmente nos equipos instalo o servidor openssh-server e subo os arquivos mediante scp (dende Windows pódese usar a utilidade pscp.exe de putty):
~$ scp -r script_esc_5C.tar.gz asir@192.168.1.150:
script_esc_5C.tar.gz 100% 1252 958.3KB/s 00:00
Unha vez subido procedemos a descomprimilo:
~$ tar zxvf script_esc_5C.tar.gz
script_esc_5C/profile_WAN script_esc_5C/network_3IPS_PLANTILLA.yml script_esc_5C/config_server_incus.yml script_esc_5C/ script_esc_5C/escenario_5C.sh ~$ cd script_esc_5C/ ~/script_esc_5C$ chmod 755 escenario_5C.sh. ~/script_esc_5C$ ls -lhF <pre> total 16K -rw-rw-r-- 1 asir asir 2,1K feb 7 22:10 config_server_incus.yml -rwxr-xr-x 1 asir asir 1,7K feb 7 22:11 escenario_5C.sh* -rw-rw-r-- 1 asir asir 211 feb 7 22:07 network_3IPS_PLANTILLA.yml -rw-rw-r-- 1 asir asir 190 feb 7 22:03 profile_WAN
~/script_esc_5C$ ./escenario_5C.sh
----- Escenario 5C -----
Seleccionar a operación:
1. Crear escenario
2. Parar server
3. Arrincar server
4. Borrar escenario
------
1
Crear escenario
Network wan created
Perfil WAN creado
------------------------------
creando server
------------------------------
Launching server-https
+--------------+---------+-------------------+----------+-----------+----------------------+
| NAME | STATE | IPV4 | PROFILES | SNAPSHOTS | LAST USED AT |
+--------------+---------+-------------------+----------+-----------+----------------------+
| server-https | RUNNING | 192.0.2.13 (eth0) | WAN | 0 | 2026/02/07 22:22 CET |
| | | 192.0.2.12 (eth0) | | | |
| | | 192.0.2.11 (eth0) | | | |
+--------------+---------+-------------------+----------+-----------+----------------------+
Tras deixar actuar un par de minutor a cloud-init para a configuración inicial da máquina, verifícase que todo foi ben:
~/script_esc_5C$ incus shell server-https ~# tail -f /var/log/cloud-init-output.log
...
To activate the new configuration, you need to run:
systemctl restart apache2
Enabling site default-ssl.
To activate the new configuration, you need to run:
systemctl reload apache2
--2026-02-07 22:24:57-- https://www.adminer.org/latest.php
Resolving www.adminer.org (www.adminer.org)... 95.168.218.179, 2a01:28:ca:112::1:907
Connecting to www.adminer.org (www.adminer.org)|95.168.218.179|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: static/download/5.4.1/adminer-5.4.1.php [following]
--2026-02-07 22:24:57-- https://www.adminer.org/static/download/5.4.1/adminer-5.4.1.php
Reusing existing connection to www.adminer.org:443.
HTTP request sent, awaiting response... 200 OK
Length: 507471 (496K) [application/octet-stream]
Saving to: ‘/var/www/html/adminer.php’
0K .......... .......... .......... .......... .......... 10% 467K 1s
50K .......... .......... .......... .......... .......... 20% 965K 1s
100K .......... .......... .......... .......... .......... 30% 10.9M 0s
150K .......... .......... .......... .......... .......... 40% 1.02M 0s
200K .......... .......... .......... .......... .......... 50% 28.6M 0s
250K .......... .......... .......... .......... .......... 60% 16.3M 0s
300K .......... .......... .......... .......... .......... 70% 23.7M 0s
350K .......... .......... .......... .......... .......... 80% 22.4M 0s
400K .......... .......... .......... .......... .......... 90% 1.06M 0s
450K .......... .......... .......... .......... ..... 100% 114M=0.3s
2026-02-07 22:24:58 (1.82 MB/s) - ‘/var/www/html/adminer.php’ saved [507471/507471]
Cloud-init v. 25.2-0ubuntu1~22.04.1 finished at Sat, 07 Feb 2026 21:24:58 +0000. Datasource DataSourceNoCloud [seed=/var/lib/cloud/seed/nocloud-net]. Up 144.59 seconds
root@server-https:~# cloud-init status
status: done
Configurar a resolución DNS dende os clientes
Para poder acceder ós sitios web dende os clientes hai que configurar a resolución dns.
Hai dúas posibles solucións:
- Instalar un servidor dns cunha zona para cada un dos dominios tenda1.example e tenda2.example.
- Nos equipos cliente poden engadirse as entradas correspondentes ós hosts www.tenda1.example e www.tenda2.example no arquivo hosts.
Aínda que non é a mellor solución, por ser un escenario de probas escolleuse a segunda por ser a máis rápida e sinxela. A modo de exemplo así quedaría o arquivo hosts dun cliente linux:
$ sudo nano /etc/hosts
127.0.0.1 localhost 127.0.1.1 lxd 192.0.2.11 www.tenda1.example 192.0.2.12 www.tenda2.example # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters
Probamos a resolución DNS e a conexión co server dende o equipo cliente:
$ ping -c 2 www.tenda1.example
PING www.tenda1.example (192.0.2.11) 56(84) bytes of data. 64 bytes from www.tenda1.example (192.0.2.11): icmp_seq=1 ttl=64 time=0.095 ms 64 bytes from www.tenda1.example (192.0.2.11): icmp_seq=2 ttl=64 time=0.086 ms --- www.tenda1.example ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1004ms rtt min/avg/max/mdev = 0.086/0.090/0.095/0.010 ms
$ ping -c 2 www.tenda2.example
PING www.tenda2.example (192.0.2.12) 56(84) bytes of data. 64 bytes from www.tenda2.example (192.0.2.12): icmp_seq=1 ttl=64 time=0.131 ms 64 bytes from www.tenda2.example (192.0.2.12): icmp_seq=2 ttl=64 time=0.104 ms --- www.tenda2.example ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 999ms rtt min/avg/max/mdev = 0.104/0.117/0.131/0.017 ms
En sistemas Windows habería que editar, como administrador, o arquivo C:\Windows\System32\drivers\etc\hosts e engadir as liñas:
192.0.2.11 www.tenda1.example 192.0.2.12 www.tenda2.example
Apache, http e virtualhosts
No caso de non usar o script, hai que instalar o servidor web Apache no servidor:
$ sudo apt update $ sudo apt install apache2
Verifícase que o servidor web Apache está correndo:
$ sudo ss -ltnp
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:* users:(("systemd-resolve",pid=168,fd=13))
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=216,fd=3))
LISTEN 0 511 *:80 *:* users:(("apache2",pid=1445,fd=4),("apache2",pid=1444,fd=4),("apache2",pid=1443,fd=4))
LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=216,fd=4))
Accedendo dende un cliente ó servidor obtense a páxina principal do sitio por defecto:
Sitio Web por defecto
Fig. Páxina por defecto de Apache en http://192.0.2.13
En Linux Ubuntu Server os arquivos de configuración do servidor Apache están na carpeta /etc/apache2:
$ ls -lhF /etc/apache2/
total 32K -rw-r--r-- 1 root root 7.1K Mar 8 17:32 apache2.conf drwxr-xr-x 2 root root 7 May 7 17:58 conf-available/ drwxr-xr-x 2 root root 7 May 7 17:58 conf-enabled/ -rw-r--r-- 1 root root 1.8K Feb 23 2021 envvars -rw-r--r-- 1 root root 31K Feb 23 2021 magic drwxr-xr-x 2 root root 143 May 7 17:58 mods-available/ drwxr-xr-x 2 root root 31 May 7 17:58 mods-enabled/ -rw-r--r-- 1 root root 320 Feb 23 2021 ports.conf drwxr-xr-x 2 root root 4 May 7 17:58 sites-available/ drwxr-xr-x 2 root root 3 May 7 17:58 sites-enabled
En Apache 2.X hai que diferenciar entre sitios web dispoñibles e sitios habilitados. Os dispoñibles non son accesibles por parte dos clientes; en cambio, os habilitados sí.
Os arquivos dos sitios web dispoñibles poden verse en /etc/apache2/sites-available/ e os habilitados poden verse en /etc/apache2/sites-enabled/.
A instalación de Apache por defecto ven con dous sitios dispoñibles (un para http e outro para https) estando activado unicamente o sitio para acceso por http:
$ ls -lhF /etc/apache2/sites-available/ total 6.5K -rw-r--r-- 1 root root 1.4K Feb 23 2021 000-default.conf -rw-r--r-- 1 root root 6.2K Feb 23 2021 default-ssl.conf ubuntu@server5C:~$ ls -lhF /etc/apache2/sites-enabled/ total 512 lrwxrwxrwx 1 root root 35 May 7 17:58 000-default.conf -> ../sites-available/000-default.conf
Estos arquivos de configuración poden usarse como punto de partida para crear novos sitios web; de feito, así o faremos neste escenario. A continuación crease o arquivo de configuración do sitio web para www.tenda1.example tomando como punto de partida o arquivo de configuración do sitio por defecto:
$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/www.tenda1.example.conf $ sudo nano /etc/apache2/sites-available/www.tenda1.example.conf
<VirtualHost 192.0.2.11:80>
ServerName www.tenda1.example
ServerAdmin webmaster@localhost
DocumentRoot /var/www/tenda1.example
ErrorLog ${APACHE_LOG_DIR}/tenda1.example_error.log
CustomLog ${APACHE_LOG_DIR}/tenda1.example_access.log combined
</VirtualHost>
Personalízanse as directivas:
- Virtualhost: indícase a IP e porto asociado ó sitio web.
- ServerName: nome de dominio asociado ó virtualhost.
- DocumentRoot: carpeta onde estarán os arquivos do sitio web.
- ErrorLog e CustomLog: para indicar os arquivos de logs do sitio web. Especificáronse uns propios para o sitio www.tendaprobas1.com para non compartilos con outros dominios.
Créase o directorio e a páxina principal do sirio www.tendaprobas1.com:
$ sudo mkdir /var/www/tenda1.example $ sudo nano /var/www/tenda1.example/index.html
<html> <head><title>Tenda Probas 1</title></head> <body> <b>TENDAPROBAS1</b> </body> </html>
Actívase o sitio:
$ sudo a2ensite www.tenda1.example.conf
Enabling site www.tenda1.example. To activate the new configuration, you need to run: systemctl reload apache2
$ sudo systemctl reload apache2
Usando o comando apache2ctl podemos ver os sitios servidos polo servidor Apache e verificamos que o sitio www.tenda1.example está activo e correndo no porto 80/tcp da IP 192.0.2.11.
Estamos a traballar con hosts virtuais baseados en IP; é dicir, cada sitio ten a súa propia combinación IP-porto:
$ sudo apache2ctl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: 192.0.2.11:80 www.tenda1.example (/etc/apache2/sites-enabled/www.tenda1.example.conf:1) *:80 127.0.0.1 (/etc/apache2/sites-enabled/000-default.conf:1) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/var/log/apache2/error.log" Mutex watchdog-callback: using_defaults Mutex default: dir="/var/lock/apache2" mechanism=fcntl PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 Group: name="www-data" id=33 ubuntu@server5C:~$
Se accedemos dende un navegador web:
Tenda 1
Fig. Acceso por http ó sitio www.tenda1.example
Repítese o proceso para www.tenda2.example
$ sudo cp /etc/apache2/sites-available/www.tenda1.example.conf /etc/apache2/sites-available/www.tenda2.example.conf $ sudo nano /etc/apache2/sites-available/www.tenda2.example.conf
<VirtualHost 192.0.2.12:80>
ServerName www.tenda2.example
ServerAdmin webmaster@localhost
DocumentRoot /var/www/tenda2.example
ErrorLog ${APACHE_LOG_DIR}/tenda2.example_error.log
CustomLog ${APACHE_LOG_DIR}/tenda2.example_access.log combined
</VirtualHost>
sudo mkdir /var/www/tenda2.example sudo nano /var/www/tenda2.example/index.html
<html> <head><title>Tenda Probas 2</title></head> <body> <b>TENDAPROBAS2</b> </body> </html>
$ sudo a2ensite www.tenda2.example.conf
Enabling site www.tenda2.example. To activate the new configuration, you need to run: systemctl reload apache2
$ sudo systemctl reload apache2 $ ls -lhF /etc/apache2/sites-enabled/
total 1.5K lrwxrwxrwx 1 root root 35 May 7 17:58 000-default.conf -> ../sites-available/000-default.conf lrwxrwxrwx 1 root root 42 May 7 18:02 www.tenda1.example.conf -> ../sites-available/www.tenda1.example.conf lrwxrwxrwx 1 root root 42 May 7 18:04 www.tenda2.example.conf -> ../sites-available/www.tenda2.example.conf
$ sudo apache2ctl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: 192.0.2.11:80 www.tenda1.example (/etc/apache2/sites-enabled/www.tenda1.example.conf:1) 192.0.2.12:80 www.tenda2.example (/etc/apache2/sites-enabled/www.tenda2.example.conf:1) *:80 127.0.0.1 (/etc/apache2/sites-enabled/000-default.conf:1) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/var/log/apache2/error.log" Mutex watchdog-callback: using_defaults Mutex default: dir="/var/lock/apache2" mechanism=fcntl PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 Group: name="www-data" id=33 ubuntu@server5C:~$
Se accedemos dende un navegador web:
Sitio Web tenda 2
Fig. Acceso por http ó sitio www.tenda2.example
Neste momento temos configurado o acceso por http ós sitios www.tenda1.example e www.tenda2.example. Na seguinte sección configuraremos o acceso por https.
Apache con https
Neste momento xa está configurado o acceso por http ós dous sitios web. Para configurar o acceso por https seguiranse os seguintes pasos:
- Activar o módulo ssl en Apache.
- Crear un arquivo de configuración para o acceso por https para o sitio web, onde se indicará a ubicación do certificado do sitio (clave pública) e a ubicación da clave privada correspondente.
- Habilitar o sitio https.
Activar módulo SSL en Apache
O soporte SSL/TLS ven dado por openssl, pero o módulo ven desactivado por defecto.
Para activar o módulo ssl en Apache hai que usar o comando a2enmod:
$ sudo a2enmod ssl
Considering dependency setenvif for ssl: Module setenvif already enabled Considering dependency mime for ssl: Module mime already enabled Considering dependency socache_shmcb for ssl: Enabling module socache_shmcb. Enabling module ssl. See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates. To activate the new configuration, you need to run: systemctl restart apache2
$ sudo systemctl restart apache2 $ sudo ss -lntp
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:* users:(("systemd-resolve",pid=168,fd=13))
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=216,fd=3))
LISTEN 0 511 *:80 *:* users:(("apache2",pid=2102,fd=4),("apache2",pid=2101,fd=4),("apache2",pid=2100,fd=4))
LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=216,fd=4))
LISTEN 0 511 *:443 *:* users:(("apache2",pid=2102,fd=6),("apache2",pid=2101,fd=6),("apache2",pid=2100,fd=6))
Revisando o arquivo de configuración de exemplo /etc/apache2/sites-available/default-ssl.conf pódense atopar as tres directivas principais para configurar o acceso por https nun sitio web:
- SSLEngine: permite habilitar ou deshabilitar o uso do SSL/TLS para o sitio web.
- SSLCertificateFile: ruta ó arquivo do certificado do sitio web.
- SSLCertificateKeyFile: ruta ó arquivo da clave privada asociada ó certificado do sitio web.
cat /etc/apache2/sites-available/default-ssl.conf
... SSLEngine on # A self-signed (snakeoil) certificate can be created by installing # the ssl-cert package. See # /usr/share/doc/apache2/README.Debian.gz for more info. # If both key and certificate are stored in the same file, only the # SSLCertificateFile directive is needed. SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key ...
Xeración de certificados con openssl
No arquivo de configuración de exemplo do sitio https por defecto aparece ssl-cert-snakeoil.key que é un certificado autoasinado xerado durante a instalación de apache que permite levantar un sitio https rápidamente co arquivo de configuración de exemplo.
Como non estamos a traballar con dominios de verdade usaremos certificados creados por nós. Aínda que existen diferentes formas de crear certificados dixitais autoasinados, empregaremos a forma máis sinxela e rápida. En primeiro lugar crearemos unha carpeta dentro do directorio /etc/apache2 chamada certificados, para gardar nelas os certificados e claves privadas asociadas e despois procedemos a xerar o certificado autoasinado e clave privada para www.tenda1.example:
sudo mkdir /etc/apache2/certificados sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/certificados/www.tenda1.example.key -out /etc/apache2/certificados/www.tenda1.example.crt
Generating a 2048 bit RSA private key ..........................+++ ...............................+++ writing new private key to '/etc/apache2/certificados/www.tenda1.example.key' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:ES State or Province Name (full name) [Some-State]:España Locality Name (eg, city) []:Santiago Organization Name (eg, company) [Internet Widgits Pty Ltd]:Tenda Probas 1 Organizational Unit Name (eg, section) []:Dpto. Ventas Common Name (e.g. server FQDN or YOUR name) []:www.tenda1.example Email Address []:admin@tenda1.example
A continuación explícase cada unha das partes do comando:
- openssl: comando para crear e xestionar certificados, claves, …
- req: serve para crear CSR (Certificate Signing Request) e certificados.
- -x509: opción para xerar un certificado autoasinado en vez dun CSR.
+ -nodes: indica que a clave privada non esté protexida cunha passphrase. Protexer a clave privada cunha passphrase obriga a ter que introducila a man cada vez que o servizo apache se reinicie.
- -days 365: permite especificar o número de días de validez do certificado (neste caso 365 días).
- -newkey rsa:2048: crea a solicitude de certificado e unha nova clave privada ó mesmo tempo. Esto é necesario xa que se está creando unha nova clave privada e non se está a traballar sobre unha clave creada con anterioridade. O parámetro rsa:2048 indica que a clave debe ser de tipo RSA cunha lonxitude de 2048 bits.
- -keyout: arquivo para a clave privada a xerar.
- -out: arquivo para o certificado a xerar.
Deste xeito créase o certificado autoasinado e a clave privada, que son gardados nunha carpeta previamente creada e chamada certificados/
$ ls -lhF /etc/apache2/certificados/
total 4.5K -rw-r--r-- 1 root root 1.5K May 7 18:40 www.tenda1.example.crt -rw------- 1 root root 1.7K May 7 18:39 www.tenda1.example.ke
Unha vez creado o certificado e a clave privada asociada, créase un arquivo de configuración para acceder a tenda1 por https a partir do arquivo de configuración para http, modificando o porto e engadindo as directivas de SSL/TLS:
$ sudo cp /etc/apache2/sites-available/www.tenda1.example.conf /etc/apache2/sites-available/www.tenda1.example-ssl.conf $ sudo nano /etc/apache2/sites-available/www.tenda1.example-ssl.conf
<VirtualHost 192.0.2.11:443>
ServerName www.tenda1.example
ServerAdmin webmaster@localhost
DocumentRoot /var/www/tenda1.example
SSLEngine on
SSLCertificateFile /etc/apache2/certificados/www.tenda1.example.crt
SSLCertificateKeyFile /etc/apache2/certificados/www.tenda1.example.key
ErrorLog ${APACHE_LOG_DIR}/tenda1.example_error.log
CustomLog ${APACHE_LOG_DIR}/tenda1.example_access.log combined
</VirtualHost>
Actívase o novo sitio:
$ sudo a2ensite www.tenda1.example-ssl.conf
Enabling site www.tenda1.example-ssl. To activate the new configuration, you need to run: systemctl reload apache2
$ sudo systemctl reload apache2 $ sudo apache2ctl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: 192.0.2.11:443 www.tenda1.example (/etc/apache2/sites-enabled/www.tenda1.example-ssl.conf:1) 192.0.2.11:80 www.tenda1.example (/etc/apache2/sites-enabled/www.tenda1.example.conf:1) 192.0.2.12:80 www.tenda2.example (/etc/apache2/sites-enabled/www.tenda2.example.conf:1) *:80 127.0.0.1 (/etc/apache2/sites-enabled/000-default.conf:1) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/var/log/apache2/error.log" Mutex watchdog-callback: using_defaults Mutex ssl-stapling-refresh: using_defaults Mutex ssl-stapling: using_defaults Mutex ssl-cache: using_defaults Mutex default: dir="/var/run/apache2/" mechanism=default PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 Group: name="www-data" id=33
Cando se acceda a https://www.tenda1.example aparecerá o aviso de erro (ERROR_SELF_SIGNED_CERT) no certificado debido a que é un certificado autosinado; e polo tanto, o navegador non coñece a autoridade emisora. Por suposto, no caso de empregar un certificado emitido por unha autoridade recoñecida polo navegador esta mensaxe non aparecería. Aceptando a excepción, cárgase a web:
Tenda 1 https
Fig. Erro error_self_signed_cert ó ser un certificado autofirmado e non poder verificalo
Certificado sitio web tenda1
Fig. Información recollida no certificado. Fixarse que os campos Emitido para e Emitido por coinciden
Sitio Web tenda 1
Fig. Acceso por https ó sitio www.tenda1.example
Repetimos o proceso para tenda2:
$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/certificados/www.tenda2.example.key -out /etc/apache2/certificados/www.tenda2.example.crt
Generating a 2048 bit RSA private key
.................................................................................................................................+++
....................................................................+++
writing new private key to '/etc/apache2/certificados/www.tenda2.example.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:ES
State or Province Name (full name) [Some-State]:España
Locality Name (eg, city) []:Santiago
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Tenda Probas 2
Organizational Unit Name (eg, section) []:Dpto. Ventas
Common Name (e.g. server FQDN or YOUR name) []:www.tenda2.example
Email Address []:admin@tenda2.example
ubuntu@server5C:~$ sudo cp /etc/apache2/sites-available/www.tenda2.example.conf /etc/apache2/sites-available/www.tenda2.example-ssl.conf
ubuntu@server5C:~$ sudo nano /etc/apache2/sites-available/www.tenda2.example-ssl.conf
<VirtualHost 192.0.2.12:443>
ServerName www.tenda2.example
ServerAdmin webmaster@localhost
DocumentRoot /var/www/tenda2.example
SSLEngine on
SSLCertificateFile /etc/apache2/certificados/www.tenda2.example.crt
SSLCertificateKeyFile /etc/apache2/certificados/www.tenda2.example.key
ErrorLog ${APACHE_LOG_DIR}/tenda2.example_error.log
CustomLog ${APACHE_LOG_DIR}/tenda2.example_access.log combined
</VirtualHost>
$ sudo a2ensite www.tenda2.example-ssl.conf
Enabling site www.tenda2.example-ssl. To activate the new configuration, you need to run: systemctl reload apache2
$ sudo systemctl reload apache2 $ sudo apache2ctl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message VirtualHost configuration: 192.0.2.11:443 www.tenda1.example (/etc/apache2/sites-enabled/www.tenda1.example-ssl.conf:1) 192.0.2.11:80 www.tenda1.example (/etc/apache2/sites-enabled/www.tenda1.example.conf:1) 192.0.2.12:443 www.tenda2.example (/etc/apache2/sites-enabled/www.tenda2.example-ssl.conf:1) 192.0.2.12:80 www.tenda2.example (/etc/apache2/sites-enabled/www.tenda2.example.conf:1) *:80 127.0.0.1 (/etc/apache2/sites-enabled/000-default.conf:1) ServerRoot: "/etc/apache2" Main DocumentRoot: "/var/www/html" Main ErrorLog: "/var/log/apache2/error.log" Mutex ssl-stapling: using_defaults Mutex ssl-cache: using_defaults Mutex default: dir="/var/run/apache2/" mechanism=default Mutex watchdog-callback: using_defaults Mutex ssl-stapling-refresh: using_defaults PidFile: "/var/run/apache2/apache2.pid" Define: DUMP_VHOSTS Define: DUMP_RUN_CFG User: name="www-data" id=33 Group: name="www-data" id=33
Accedendo cun navegador web:
Sitio Web tenda 2 https
Fig. Erro error_self_signed_cert ó ser un certificado autofirmado e non poder verificalo
Certificado sitio web tenda2
Fig. Certificado autofirmado para www.tenda2.example
Sitio Web tenda 2 https
Fig. Acceso por https ó sitio www.tenda2.example