How do I set $_SERVER['HTTPS'] on?

I am trying to deploy moodle on and I am able to view the moodle install screen via docker, but the CSS and JS do not seem to be working. I have looked into the cause and found that the server variable $_SERVER[‘HTTPS’] is not set, even though the URL is https. How can I set $_SERVER[‘HTTPS’] to on?

here is Dockerfile.

FROM php:7.4-apache
COPY moodle /var/www/html
RUN apt update \
    && apt install -y --no-install-recommends zlib1g-dev libzip-dev libpq-dev libpng-dev libicu-dev libxml2 libxml2-dev \
    && apt -y clean \
    && docker-php-ext-install zip pdo pdo_pgsql pgsql gd intl xmlrpc soap opcache \
    && mkdir /var/www/moodledata \
    && chmod 0777 /var/www/moodledata \
    && chmod -R 0755 /var/www/html

Perhaps this is helpful? Configuring Environment Variables and Secrets | Render

Hey @matsumaru-t Is there any chance that the urls for your assets (images/css/js) are using http rather than https? That would explain why the $_SERVER[‘HTTPS’] is off even when you access the site in secure mode.

Thanks for the reply.

Yes, as you say the url for the asset is ‘http’, I looked at the moodle source and it seems that the url depends on the value of $_SERVER[‘HTTPS’].

However, I was able to avoid this problem by installing moodle in a different way, so I think We can close this topic.

1 Like

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