Problem
Apache isn't reporting HTTPS in the $_SERVER
variable of PHP. Certificate is correctly configured according to sslcheck.nl and the website redirects every HTTP request to the HTTPS equivalent.
$_SERVER
variable:
HTTPS
key does not existSERVER_PORT
is 80 instead of 443HTTP_X_FORWARDED_PROTO
is not setREQUEST_SCHEME
is http instead of https
Without these values, Symfony framework and Wordpress cannot determine if the website is running on a secure connection.
Configuration
I'm running a Bitnami LAMP stack. As far as I can tell, the server does not run a reverse proxy. The website does have mod_pagespeed configured, but I do not think that this is configured as a reverse proxy. I tried disabling mod_pagespeed for a test vhost, but Apache keeps reporting http.
What else could be the reason for Apache incorrectly reporting HTTP/HTTPS?
Update
Output from netstat -plnt
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 65034/master
tcp 0 0 127.0.0.1:2812 0.0.0.0:* LISTEN 2295/monit
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 1801/mysqld.bin
tcp 0 0 127.0.0.1:12301 0.0.0.0:* LISTEN 48346/opendkim
tcp 0 0 127.0.0.1:21 0.0.0.0:* LISTEN 731/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1889/sshd
tcp6 0 0 ::1:25 :::* LISTEN 65034/master
tcp6 0 0 :::443 :::* LISTEN 25401/httpd
tcp6 0 0 :::80 :::* LISTEN 25401/httpd
tcp6 0 0 :::22 :::* LISTEN 1889/sshd
Vhost configuration:
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot "/opt/bitnami/apps/mydomain/htdocs/web"
RewriteEngine On
#redirect non-www to https://www.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#redirect http://www. to https://www.
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
CustomLog /opt/bitnami/apache2/logs/mydomain-http.log combined
Include "/opt/bitnami/apps/mydomain/conf/httpd-app.conf"
</VirtualHost>
<VirtualHost *:443>
ServerName mydomain.com
DocumentRoot "/opt/bitnami/apps/mydomain/htdocs/web"
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
CustomLog /opt/bitnami/apache2/logs/mydomain-https.log combined
SetEnv HTTPS on #Added this to force https environment variable
Include "/opt/bitnami/apps/mydomain/conf/httpd-app.conf"
</VirtualHost>
netstat -plnt
or similar)netstat
command, along with your relevant Apache configs?