Virtual Host SSL Definition

Hello all,

I am having problems trying to define my Apache Virtual Host configuration file properly for SSL traffic. My configuration file looks as follows:

<VirtualHost *:80>

ServerName example.com
ServerAdmin [email protected]
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{SERVER_NAME} = example.com [OR]
RewriteCond %{SERVER_NAME} = www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</IfModule>

<VirtualHost *:443>

ServerAdmin [email protected]
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

SSLEngine on
SSLCertificateFile /etc/cloudflare/example.com.pem
SSLCertificateKeyFile /etc/cloudflare/example.com.key

I have the port 80 section in so it rewrites to HTTPS. This does not seem to be working. Second is my SSL section proper for port 443?

Thanks,
Steve

I don’t use Apache for my sites. You’d probably have better luck at serverfault.com or stackoverflow.com for assistance in Apache configuration.

1 Like

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