0

I have setup centos with apache, enabled ssl and setup lets encrypt cert( followed this guide for ssl https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-centos-7). And used this guide to setup a new virtual host (https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-centos-7) I cannot get my 2nd virtual host to be served. it seems like it keeps using the default ssl virtual host(which seemed to have been created after installing mod_ssl). Below are my config files

Default ssl virtual host /etc/httpd/conf.d/ssl.conf

ErrorLog logs/ssl_error_log  
TransferLog logs/ssl_access_log  
LogLevel warn  
SSLEngine on  
SSLProtocol all -SSLv2 -SSLv3  
SSLCipherSuite HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA  
SSLCertificateFile /etc/pki/tls/certs/localhost.crt   
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key  
<Files ~ "\.(cgi|shtml|phtml|php3?)$">    
    SSLOptions +StdEnvVars  
</Files>  
<Directory /var/www/html/var/www/cgi-bin>  
    SSLOptions +StdEnvVars  
</Directory>  
BrowserMatch "MSIE [2-5]" \  
         nokeepalive ssl-unclean-shutdown \  
         downgrade-1.0 force-response-1.0  
CustomLog logs/ssl_request_log \  
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"  
DocumentRoot /var/www/html  

2nd SSL Virtual Host /etc/httpd/sites-available/example.co.za.conf

ServerName example.example.co.za
ServerAlias example.co.za
DocumentRoot /var/www/example.co.za/html
ErrorLog /var/www/example.co.za/log/error.log
CustomLog /var/www/example.co.za/log/requests.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.co.za [OR]
RewriteCond %{SERVER_NAME} =example.example.co.za
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

updated config requested

/etc/http/conf/httpd.conf

Listen 80  
Include conf.modules.d/*.conf  
User apache  
Group apache  
ServerAdmin root@localhost  
<Directory />  
    AllowOverride none  
    Require all denied  
</Directory>  
DocumentRoot "/var/www/html"  
<Directory "/var/www">  
    AllowOverride None  
    Require all granted  
</Directory>  
<Directory "/var/www/html">  
Options Indexes FollowSymLinks  
AllowOverride None  
    Require all granted  
</Directory>  
<IfModule dir_module>  
    DirectoryIndex index.html  
</IfModule>  
<Files ".ht*">  
    Require all denied  
</Files>  
ErrorLog "logs/error_log"  
LogLevel warn  
<IfModule log_config_module>  
 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined  
    LogFormat "%h %l %u %t \"%r\" %>s %b" common  
<IfModule logio_module>  
     LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio  
    </IfModule>  
    CustomLog "logs/access_log" combined  
</IfModule>  
<IfModule alias_module>  
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"  
</IfModule>  
<Directory "/var/www/cgi-bin">  
    AllowOverride None  
    Options None  
    Require all granted  
</Directory>  
<IfModule mime_module>  
  TypesConfig /etc/mime.types  
AddType application/x-compress .Z  
    AddType application/x-gzip .gz .tgz  
    AddType text/html .shtml  
    AddOutputFilter INCLUDES .shtml  
</IfModule>  
AddDefaultCharset UTF-8  
<IfModule mime_magic_module>  
   MIMEMagicFile conf/magic  
</IfModule>  
EnableSendfile on  
IncludeOptional conf.d/*.conf  
IncludeOptional sites-enabled/*.conf  
Include /etc/httpd/sites-available/example.co.za-le-ssl.conf  

/etc/http/conf.d/ssl.conf

Listen 443 https  
SSLPassPhraseDialog exec:/usr/libexec/httpd-ssl-pass-dialog  
SSLSessionCache         shmcb:/run/httpd/sslcache(512000)  
SSLSessionCacheTimeout  300  
SSLRandomSeed startup file:/dev/urandom  256  
SSLRandomSeed connect builtin  
SSLCryptoDevice builtin  
<VirtualHost _default_:443>  
ErrorLog logs/ssl_error_log  
TransferLog logs/ssl_access_log  
LogLevel warn  
SSLEngine on  
SSLProtocol all -SSLv2 -SSLv3  
SSLCipherSuite HIGH:3DES:!aNULL:!MD5:!SEED:!IDEA  
SSLCertificateFile /etc/pki/tls/certs/localhost.crt  
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key  
<Files ~ "\.(cgi|shtml|phtml|php3?)$">  
    SSLOptions +StdEnvVars  
</Files>  
<Directory /var/www/html/var/www/cgi-bin>  
    SSLOptions +StdEnvVars  
</Directory>  
BrowserMatch "MSIE [2-5]" \  
         nokeepalive ssl-unclean-shutdown \  
         downgrade-1.0 force-response-1.0  
CustomLog logs/ssl_request_log \  
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"  
DocumentRoot /var/www/html  
</VirtualHost>  

/etc/httpd/sites-available/example.co.za-le-ssl.conf

<IfModule mod_ssl.c>  
<VirtualHost *:443>  
    ServerName example.example.co.za  
    ServerAlias example.co.za  
    DocumentRoot /var/www/example.co.za/html  
    ErrorLog /var/www/example.co.za/log/error.log  
    CustomLog /var/www/example.co.za/log/requests.log combined  
SSLCertificateFile /etc/letsencrypt/live/example.example.co.za/cert.pem  
SSLCertificateKeyFile /etc/letsencrypt/live/example.example  
.co.za/privkey.pem  
Include /etc/letsencrypt/options-ssl-apache.conf  
SSLCertificateChainFile /etc/letsencrypt/live/example.example.co.za/chain.pem  
</VirtualHost>  
</IfModule>  
New contributor
code-is-life is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Please also provide the <virtualhost> lines – Gerald Schneider May 13 at 10:28
  • and: did you create symlink from sites-enabled/example.co.za.conf to sites-available/example.co.za.conf using a2ensite example.co.za? – Gerald Schneider May 13 at 10:37
  • best way for me to see if symlink has been created? would it just be a case of both .conf files being in both sites enabled and available? – code-is-life May 13 at 11:09
  • Just run ls -l on that dir – Gerald Schneider May 13 at 11:28
  • root@examplesvc /etc/httpd/sites-available $ ls -l total 12 -rw-r--r--. 1 root root 506 May 2 04:58 example.co.za.conf -rw-r--r--. 1 root root 650 May 2 04:58 example.co.za-le-ssl.conf -rw-r--r--. 1 root root 252 May 2 12:55 dev.conf – code-is-life May 13 at 11:45

Your Answer

code-is-life is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.