0

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]
  • Presumably you have unique ServerNames 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 <VirtualHost *:80>)? 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 8:50
  • and what should I take as appropriate VirtualHost container? are you specifically talking about SNI ? – Ramesh Pareek Oct 30 '17 at 14:15

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.