sslssl-certificatecpanelvirtualhostwhm

Snipe-IT / Cpanel / WHM auto SSL issue


Maybe some of you have done it and could help me. I use Cpanel and WHM. Basically I installed snipe-it and had to create a custom VirtualHost in WHM via include file. The site is a subdomain.(( # To customize this VirtualHost use an include file at the following location. )) I have created two VirtualHosts include files one is STD(http) other is SSL(http).

Both have the same information in them;

<Directory /home/sitename/public_html/foldername>
                Allow From All
                AllowOverride All
                Options -Indexes
</Directory>
        DocumentRoot /home/sitename/public_html/foldername/public
        ServerName foldername

Snipe-IT works, but I have problems with auto ssl. Can't seem to get it to work. Also, the .well-known folder is not accessible. My bet is the current include file / VirtualHost is the problem. Have tried to modify it and add diferent things, but it's not helping. Have been googling all around today, maybe some of you have done / have more knowledge.

Auto SSL return the DNS DCV: No local authority: “sitename.com”; HTTP DCV: The system queried for a temporary file at “http://sitename.com/.well-known/pki-validation/C5D6E8C52B231314C3DB7ACDD.txt”, but the web server responded with the following error: 404 (Not Found). A DNS (Domain Name System) or web server misconfiguration may exist. AutoSSL works completely fine with main domain, Subdomain has the same IP as main domain.

My Snipe-IT.example.com directory contains .htaccess file:

    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    # Make sure .env files not not browseable if in a sub-directory.
    <FilesMatch "\.env$">
       # Apache 2.2
       <IfModule !authz_core_module>
          Deny from all
       </IfModule>
       
       # Apache 2.4+
       <IfModule authz_core_module>
          Require all denied
       </IfModule>
    </FilesMatch>
    
</IfModule>

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
   php_flag display_errors Off
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 128M
   php_value post_max_size 50M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php74"
   php_value upload_max_filesize 40M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors Off
   php_value max_execution_time 30
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 128M
   php_value post_max_size 50M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php74"
   php_value upload_max_filesize 40M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

Solution

  • After spending countless hours googling and searching for solution, finally figured it out by myself. Added this at the start of my VirtualHost config file and everything started to work:

      Alias /.well-known/pki-validation/ /home/mysite/public_html/mysubdomain/.well-known/pki-validation/
       <Directory /home/mysite/public_html/mysubdomain/.well-known/pki-validation/>
              AllowOverride None
              Require all granted
              Satisfy Any
        </Directory>
    

    So the full VirtualHost include file looks like this:

      Alias /.well-known/pki-validation/ /home/mysite/public_html/mysubdomain/.well-known/pki-validation/
       <Directory /home/mysite/public_html/mysubdomain/.well-known/pki-validation/>
              AllowOverride None
              Require all granted
              Satisfy Any
        </Directory>
    
    <Directory /home/mysite/public_html/mysubdomain>
                    Allow From All
                    AllowOverride All
                    Options -Indexes
    </Directory>
            DocumentRoot /home/mysite/public_html/mysubdomain/public
            ServerName servername.com
    
    

    I am not sure if this causes any security issues.