2

I'm trying to install ssl on multiple virtual hosts and domains on same IP. I am using multiple .conf files for this.

Already have three working domains on this IP with SSL. But while trying to install ssl on one more domain with command:

certbot-auto --apache -d mydomain.com -d www.mydomain.com

get this error:

The selected vhost would conflict with other HTTPS VirtualHosts within Apache. Please select another vhost or add ServerNames to your configuration. VirtualHost not able to be selected.

Here is the configuration I have in mydomain.conf

    <VirtualHost *:80>
            ServerAdmin webmaster@localhost
            DocumentRoot /var/www/mydomain/
               ServerName mydomain.com
               ServerAlias www.mydomain.com
            <Directory /var/www/mydomain/>
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
            </Directory>

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

RewriteEngine on
RewriteCond %{SERVER_NAME} =www.mydomain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Ramesh Pareek
  • 121
  • 1
  • 3
  • Presumably you have unique `ServerName`s defined for each VirtualHost (and your main server config)? _Aside:_ That mod_rewrite redirect would seem to be in error (when used outside of the ``)? You should be checking against `HTTP_HOST`, rather than `SERVER_NAME` - although that may not make much difference depending on how `UseCanonicalName` is set. (Ideally, you would use a `Redirect` in the appropriate `VirtualHost` container instead of mod_rewrite here.) – MrWhite Oct 30 '17 at 08:50
  • and what should I take as `appropriate VirtualHost container`? are you specifically talking about SNI ? – Ramesh Pareek Oct 30 '17 at 14:15

0 Answers0