cachethq / cachet

🚦 The open-source status page system.
https://cachethq.io
MIT License
13.79k stars 1.55k forks source link

Mixed-Context blocking error by webrowser when attempting to place Cachet behind an SSL NGINX Proxy. #4377

Closed elapse2039 closed 4 months ago

elapse2039 commented 4 months ago

Setup:

  1. docker-compose running cachet
  2. Domain pointing to NGINX Proxy using HTTPS with upstream HTTP to cachet.
  3. Using local, HTTP based URL, Cachet works fine.
  4. Using the HTTPS domain, proxied to the HTTP based Cachet is blocked by browser due to "mixed-content".

NGINX upstream proxy block...

server {
    listen 443 ssl;
    server_name <REMOVED>;
    client_max_body_size 0M;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://192.168.1.134:8011;
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    ssl_certificate /etc/letsencrypt/live/<REMOVED>fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/<REMOVED>/privkey.pem;
}

FYI The NGINX proxy is working fine for other upstream services.

Error: https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content?utm_source=mozilla&utm_medium=firefox-console-errors&utm_campaign=default

Screenshot from 2024-03-01 10-27-20

Expected: The installation guides on Cachet mention a proxy frontend to Cachet and I dont see where to provision any SSL certs for Cachet or why it is switching between https and http for mixed content. In the configuration options, the site-url is set to the https domain.

elapse2039 commented 4 months ago

I found an answer... I had to include

proxy_set_header X-Forwarded-Proto $scheme;

so...

server {
    listen 443 ssl;
    server_name <REMOVED>;
    client_max_body_size 0M;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://192.168.1.134:8011;
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    ssl_certificate /etc/letsencrypt/live/<REMOVED>/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/<REMOVED>/privkey.pem;
}