Comment configurer plusieurs sous-domaines avec SSL dans Apache?

Configuration:

  • Debian
  • Apache2
  • Wildcard SSL pour: * .exemple.com
  • sous-domaine: a.exemple.com, b.exemple.com.
  • 1 serveur dédié
  • Les sites Web sont dans NodeJS (ProxyPass …)

Pour l’instant, je suis capable de faire fonctionner un.exemple.com. Mais comment faire pour que a.example.com AND b.example.com fonctionne sur le même serveur?

/etc/apache2/site-enable/a.example.com.conf  ServerName a.example.com Redirect permanent / https://a.example.com   ServerName www.a.example.com Redirect permanent / https://a.example.com  Listen 443  ServerName a.example.com ServerAlias www.a.example.com ProxyRequests off LimitRequestLine 150000 LimitRequestFieldSize 150000  Order deny,allow Allow from all   ProxyPass http://localhost:4949/ ProxyPassReverse http://localhost:4949/  SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL SSLCertificateFile /etc/ssl/2__.example.fr.crt SSLCertificateKeyFile /root/XXXXXX.key SSLCertificateChainFile /etc/ssl/1_root_bundle.crt  

MISE À JOUR — Si j’essaie ceci:

 /etc/apache2/site-enable/b.example.com.conf  ServerName b.example.com Redirect permanent / https://b.example.com   ServerName www.b.example.com Redirect permanent / https://b.example.com /VirtualHost> Listen 443  ServerName b.example.com ServerAlias www.b.example.com ProxyRequests off LimitRequestLine 150000 LimitRequestFieldSize 150000  Order deny,allow Allow from all   ProxyPass http://localhost:6949/ ProxyPassReverse http://localhost:6949/  SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL SSLCertificateFile /etc/ssl/2__.example.fr.crt SSLCertificateKeyFile /root/XXXXXX.key SSLCertificateChainFile /etc/ssl/1_root_bundle.crt  

Je comprends ça

 [....] Restarting web server: apache2[Thu Jul 21 14:58:01 2016] [warn] module passenger_module is already loaded, skipping [Thu Jul 21 14:58:01 2016] [warn] _default_ VirtualHost overlap on port 443, the first has precedence [Thu Jul 21 14:58:01 2016] [warn] NameVirtualHost *:80 has no VirtualHosts ... waiting [Thu Jul 21 14:58:02 2016] [warn] module passenger_module is already loaded, skipping [Thu Jul 21 14:58:02 2016] [warn] _default_ VirtualHost overlap on port 443, the first has precedence [Thu Jul 21 14:58:02 2016] [warn] NameVirtualHost *:80 has no VirtualHosts (98)Address already in use: make_sock: could not bind to address [::]:443 

— METTRE À JOUR

J’ai supprimé Listen 443 sur b.exemple.com.conf

Mais maintenant, j’ai ceci:

 a.example.com ---> b.example.com b.example.com ---> b.example.com 

Le problème est que lorsque je tente d’accéder à un, je suis redirigé vers b

Qu’est-ce que je fais mal?

 /etc/apache2/site-enable/b.example.com.conf  ServerName b.example.com Redirect permanent / https://b.example.com   ServerName www.b.example.com Redirect permanent / https://b.example.com /VirtualHost>  ServerName b.example.com ServerAlias www.b.example.com ProxyRequests off LimitRequestLine 150000 LimitRequestFieldSize 150000  Order deny,allow Allow from all   ProxyPass http://localhost:6949/ ProxyPassReverse http://localhost:6949/  SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL SSLCertificateFile /etc/ssl/2__.example.fr.crt SSLCertificateKeyFile /root/XXXXXX.key SSLCertificateChainFile /etc/ssl/1_root_bundle.crt  

– MISE À JOUR TROUVÉE UNE SOLUTION:)

J’ai finalement trouvé une solution à mon problème, merci pour votre aide!

  Listen 443 NameVirtualHost *:443   ServerName www.example.fr DocumentRoot "/var/www/html/404" SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL SSLCertificateFile /etc/ssl/2__.example.fr.crt SSLCertificateKeyFile /root/XXXXX.key SSLCertificateChainFile /etc/ssl/1_root_bundle.crt   ServerName www.example.fr Redirect permanent / https://a.example.fr   ServerName a.example.fr Redirect permanent / https://a.example.fr   ServerAdmin [email protected] ServerName a.example.fr ProxyRequests off LimitRequestLine 150000 LimitRequestFieldSize 150000  Order deny,allow Allow from all   ProxyPass http://localhost:4949/ ProxyPassReverse http://localhost:4949/  SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL SSLCertificateFile /etc/ssl/2__.example.fr.crt SSLCertificateKeyFile /root/serveurA.key SSLCertificateChainFile /etc/ssl/1_root_bundle.crt   ServerName b.example.fr Redirect permanent / https://b.example.fr   ServerAdmin [email protected] ServerName b.example.fr ProxyRequests off LimitRequestLine 150000 LimitRequestFieldSize 150000  Order deny,allow Allow from all   ProxyPass http://localhost:6949/ ProxyPassReverse http://localhost:6949/  SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLCipherSuite ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL SSLCertificateFile /etc/ssl/2__.example.fr.crt SSLCertificateKeyFile /root/serveurA.key SSLCertificateChainFile /etc/ssl/1_root_bundle.crt  

Modifiez votre code virtualhost pour les caractères génériques (* .exemple.com) pour tous les sous-domaines. Pour implémenter cette fonctionnalité, votre certificate SSL doit être un caractère générique qui prend en charge plusieurs sous-domaines.

Modifier / append deux lignes dans le code du fichier apache httpd.conf ou ssl.conf

  ServerName www.example.com ServerAlias *.example.com 

Exemples :

 a.example.com b.example.com WHATEVER_SUB-DOMAIN_TEXT.example.com