Okay, so I've had no experience with SSL/HTTPS ever before, I've only ever dealt with standard HTTP. Recently I've started work on a site which will need SSL. So of course, I've gone out and researched how to and got started. I've got to the stage of installing the SSL certificate successfully - the green padlock appears and the server responds to HTTPS requests on port 443. The issue I have is that no matter what I do I cant get any pages to appear using HTTPS/SSL, however they appeared fine on port 80/HTTP (until I redirect HTTP to HTTPS that is).
Put simply I can access the HTTPS site absolutely fine, however my pages are not being sent, rather a 404 is sent for every request.
/etc/apache2/sites-available/[name].conf
<VirtualHost *:80>
ServerName [serverName]
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=302]
</VirtualHost>
<VirtualHost *:443>
ServerName [serverName]
ServerAdmin [email]
DocumentRoot [docRoot]
# I know the following SSL cert stuff is correct
SSLEngine On
SSLCertificateFile [...]/[domain].crt
SSLCertificateKeyFile [...]/[certificate].key
SSLCertificateChainFile [...]/[theotherone].crt
ErrorLog ${APACHE_LOG_DIR}/[custom]_error.log
CustomLog ${APACHE_LOG_DIR}/[custom]_access.log combined
<Directory "[docRoot]">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
I'm not sure if there is anything else you might want to look at, or any other details, but if there is let me know.
EDIT:
After some searching around in the config files I have established that for whatever reason, when connecting to HTTPS, the server is using the document root in the default configuration (/var/www/) however this default configuration is not enabled with a2ensite. I can't seem to figure where the configuration that is causing this is located
Rewrite
directives look like you are trying to run Apache behind a badly configured reverse proxy. If your Apache is serving the domain directly without any proxying, you should just drop all of theRewrite
directives and replace them with a singleRedirect
. And configure separate logfiles for eachVirtualHost
such that you can see exactly whichVirtualHost
process each request.