mercredi 29 janvier 2020

Wildcard subdomains + main domain ssl

I have a website where users get their own subdomain... and it works fine only the SSL doesn't really work... when I try after a restart to go to user1.example.com it loads the SSL certificate of example.com instead of *.example.com... so someone know how I could say to apache2 that it needs to load the first config first and then the second one?

at some point, it worked but I made an apache2 restart and after that, it stopped working... I am pretty sure that apache2 loads the exmaple.com first and that this is the mistake but Idk how to change it.

my confs

  1. 00-catchall.conf
  2. 01-exmaple.com.conf

00-catchall.conf

<VirtualHost *:80>

DocumentRoot /var/www/example.com/public/
ServerAlias *.example.com
</VirtualHost>

<VirtualHost *:443>
  Header set Access-Control-Allow-Origin "*"

ServerAlias *.example.com
DocumentRoot /var/www/example.com/public/
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/-0001/privkey.pem

</VirtualHost>

01-example.com.conf

    <VirtualHost example.com.com:80>
        ServerAdmin mail@example.com

        DocumentRoot /var/www/example.com/public/
        ServerName example.com
        CustomLog /var/www/log/example.com/access.log combined
        ErrorLog /var/www/log/example.com/error.log

<Directory /var/www/example.com/>
        AllowOverride All

</Directory>

</VirtualHost>

<VirtualHost example.com:443>
Header set Access-Control-Allow-Origin "*"



        ServerAdmin mail@example.com
        ServerName example.com

        DocumentRoot /var/www/example.com/public/
        CustomLog /var/www/log/example.com/sslaccess.log combined

        ErrorLog /var/www/log/example.com/error.log

<Directory /var/www/example.com/>
        AllowOverride All

</Directory>
    SSLEngine On
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>





Aucun commentaire:

Enregistrer un commentaire