====== Servidor web/dades ====== ===== Actualització d'HTTP a HTTPS. Configuració d'Apache - Setembre de 2022 ===== Un cop obtingut el certificat, creo múltiples servidors virtuals a Apache d'acord amb la recomanació descrita a [[https://stackoverflow.com/questions/65639594/redirect-server-aliases-to-server-name-over-https-on-apache | Redirect Server Aliases to Server Name Over HTTPS on Apache | stackoverflow.com]] en què es proposa definir tres servidors virtuals: * el primer per redirigir HTTP a HTTPS; * el segon, que escolta en HTTPS, per redirigir tots els dominis cap al domini principal; * i el tercer, que només escolta en HTTPS, per configurar el domini principal. Amb això s'aconsegueix simplificar la configuració del servidor HTTP/HTTPS.
If I got it correctly, you're trying to redirect every known domain reaching your apache to just one domain and when the connection comes as HTTP you want to redirect it to HTTPS. To keep the configuration simple, I would create 3 different virtual hosts: The first one will listen on http and include every domain you want to redirect (including the main one becuase it's listening on http). This virtualhost will redirect everything to the main domain over https: ServerName main.site.com ServerAlias mysite.example.com ServerAlias another.site.com Redirect permanent / https://main.site.com/ The second one will listen on https port and includes all the domains but the main one and redirect it to your primary domain (it's like the previous one except it doesn't include the main domain) ServerName mysite.example.com ServerAlias another.site.com Redirect permanent / https://main.site.com/ ... SSLEngine On ... In the end, the main one will just listen on https and will include only the main domain: ServerName main.site.com ... SSLEngine On ... This way, the only virtualhost requiring configuretiona (document root, locations, etc.) is the last one.
==== Servidor virtual 1: redireccionament d'HTTP a HTTPS ==== Creo el fitxer ''sermn_uab_cat-1-http.conf'' amb el següent contingut, ServerName sermn.uab.cat ServerAlias sermn.uab.es ServerAlias rmn3.uab.cat ServerAlias rmn3.uab.es Redirect permanent / https://sermn.uab.cat/ ==== Servidor virtual 2: redireccionament d'HTTPS al servidor principal ==== Creo el fitxer ''sermn_uab_cat-2-https.conf'' amb el següent contingut, ServerName sermn.uab.cat ServerAlias sermn.uab.es ServerAlias rmn3.uab.cat ServerAlias rmn3.uab.es Redirect permanent / https://sermn.uab.cat/ #### SSL CERTIFICATES SSLEngine on SSLCertificateFile ... SSLCertificateKeyFile ... ==== Servidor virtual 3: configuració del servidor HTTPS principal ==== Creo el fitxer ''sermn_uab_cat-3-https.conf'' amb el següent contingut, ServerName sermn.uab.cat #### SSL CERTIFICATES SSLEngine on SSLCertificateFile ... SSLCertificateKeyFile ... #### DOCUMENT ROOT DocumentRoot /var/www/sermn #### DIRECTORIES Options FollowSymLinks AllowOverride None ... ===== Enllaços per proves ===== ==== HTTP ==== * [[http://sermn.uab.cat]] * [[http://sermn.uab.es]] * [[http://rmn3.uab.cat]] * [[http://rmn3.uab.es]] === Aplicacions web === * [[http://sermn.uab.cat/reserves]] * [[http://sermn.uab.cat/wiki]] * [[http://sermn.uab.cat/pydio]] ==== HTTPS ==== * [[https://sermn.uab.cat]] * [[https://sermn.uab.es]] * [[https://rmn3.uab.cat]] * [[https://rmn3.uab.es]] === Aplicacions web === * [[https://sermn.uab.cat/reserves]] * [[https://sermn.uab.cat/wiki]] * [[https://sermn.uab.cat/pydio]]