One or 2 Vhosts per domain for SSL?

Hello everyone

  `
### WordPress Environment ###

Home URL: https://myDomaine.com
Site URL: https://myDomaine.com

WPress Version: 4.9

Log Directory Writable: ✔

### Server Environment ###

Server Info: Apache/2.4.10 (Debian)
PHP Version: 5.6.33-0+deb8u1

cURL Version: 7.38.0
OpenSSL/1.0.1t

### Settings ###

API Enabled: ✔
Force SSL: ✔

I’m having a bit of confusion configuring SSL with LetsEncrypt with my Wordpress.

I installed it with Certbot and it seems to work. But I would like to know if I can simplify my Apache Vhosts configuration. For the moment by default :

I have 1 Vhost file for port:#80 and a second one for https port :#443 (named ; myDomaine-le-ssl.conf).

By following several examples, I found one that integrates the 2 Apache directives.

I would like to know if this configuration is correct and if it is recommended ? Before breaking everything :slight_smile: Thanks a lot.

Here my new Vhost project :

<VirtualHost *:80>
        ServerName MyDomain.com
        ServerAlias www.MyDomain.com


      DocumentRoot /var/www/html
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined

    <Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
                Require all granted
    </Directory>

</VirtualHost>

<VirtualHost *:443>
        ServerName MyDomain.com
        ServerAlias www.MyDomain.com


    <Directory /var/www/html>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
                Require all granted
    </Directory>


        ServerAdmin contact@MyDomain.com
        DocumentRoot /var/www/MyDomain.com
        SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/MyDomain.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/MyDomain.com/privkey.pem
        SSLCACertificateFile  /home/me/domain.com.crt


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

You need one <VirtualHost> for port 80 and another one for port 443, but they can be in the same file if you want.

Thanks jmorahan, I will test.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.