In my apache config file I'm trying to set a virtual host on port 443 IF my environment variable is not dev
I have a docker container running via docker-compose which specifies the environment variables.
To check the env variables are properly set, I remote into my container:
root@4f212c1c7e23:/var/www# echo ${APP_ENV}
prod
Below is the apache config file that is apart of the volume mapped to the container
000-default.conf
:
<VirtualHost *:80>
ServerName ${DOMAIN}
ServerAdmin ${ADMIN_EMAIL}
DocumentRoot /var/www/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<IfModule "%{APP_ENV} != 'dev'">
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName ${DOMAIN}
ServerAdmin ${ADMIN_EMAIL}
DocumentRoot /var/www/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile /var/imported/ssl/main.crt
SSLCertificateKeyFile /var/imported/ssl/privkey.pem
SSLEngine on
</VirtualHost>
</IfModule>
</IfModule>
But when starting the container on production, the result in browser is "ERR_SSL_PROTOCOL_ERROR" when trying to access port 443.
My error log only reads:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.26.0.2. Set the 'ServerName' directive globally to suppress this message
Similarly the expression "%{APP_ENV} == 'prod'"
, gives the same result
When deleting the outer IfModule
in the apache config, the connection is accepted and everything works as expected.
So I'm wondering how to get the outer IfModule
condition to behave as intended?
Please let me know if there is more info I can provide