Skip to content

Blocked loading mixed active content “http://88.99.81.115:8080/api/v1" ... #106

Closed

Description

@nelsonic

Following the success of #105 (setup nginx to proxy the autobase console)
It's still not working because the console is just a UI which connects to the API on port 8080 ...

Image

http://88.99.81.115:8080/
Image

Obviously the job isn't done until autobase is fully working. 🙃
So attempting to address this now. 🧑‍💻

Activity

  1. self-assigned this
    on Mar 24, 2025
  2. moved this to More ToDo ThanCanEver Be Done in Nelson's Liston Mar 24, 2025
  3. nelsonic commented on Mar 24, 2025

    @nelsonic
    MemberAuthor

    I think this just means we need to run the API server on the same domain ...
    But to do that we need to create a proxy through nginx ...
    I tried adding the config this morning:

    server {
      listen 8080;
      server_name autobase.dwy.is;
      
    	location / {
        proxy_pass http://172.17.0.1:8080;
    	}
    }

    But it failed test:

    2025/03/24 19:54:14 [emerg] 67966#67966: "server" directive is not allowed here in /etc/nginx/sites-enabled/autobase:1
    nginx: configuration file /etc/nginx/sites-enabled/autobase test failed

    But the syntax passes check: https://www.getpagespeed.com/check-nginx-config

    Image

    Read a bunch of FAQ:
    https://serverfault.com/questions/1077260/nginx-how-to-forward-8080

    Still scratching my head ... 🙃

  4. nelsonic commented on Mar 25, 2025

    @nelsonic
    MemberAuthor

    Got nginx to work with the following config:

    server {
      listen 8080;
      server_name autobase.dwy.is;
    
      location / {
        proxy_pass http://172.17.0.1:8082/;
      }
    }

    But still getting the same error:

    Blocked loading mixed active content http://88.99.81.115:8080/api/v1

    Image

    The problem is that the console is being loaded over HTTPS whereas the API is loaded over HTTP (no SSL/TLS!)
    Ref: https://stackoverflow.com/questions/18251128/why-am-i-suddenly-getting-a-blocked-loading-mixed-active-content

    So the only way around this is for the API content to be requested/served over SSL ... 😬

  5. nelsonic commented on Mar 25, 2025

    @nelsonic
    MemberAuthor

    Updated nginx config to:

    server {
      listen 80;
      server_name autobase.dwy.is;
    
      return 301 https://$host$request_uri;
    }
    
    server {
      server_name autobase.dwy.is;
    
      # stackoverflow.com/questions/14501047/add-response-header-nginx-proxy-pass
      # 1. hide the Access-Control-Allow-Origin from the server response
      proxy_hide_header Access-Control-Allow-Origin;
      # 2. add a new custom header that allows all * origins instead
      add_header Access-Control-Allow-Origin $http_origin;
      add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, HEAD';
      add_header X-Upstream $upstream_addr always;
    
      location / {
        proxy_pass http://172.17.0.1:82;
      }
    
      listen 443 ssl; # managed by Certbot
      ssl_certificate /etc/letsencrypt/live/dwy.is/fullchain.pem; # managed by Certbot
      ssl_certificate_key /etc/letsencrypt/live/dwy.is/privkey.pem; # managed by Certbot
      include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    }
    
    server {
      listen 8080 ssl;
      ssl_certificate /etc/letsencrypt/live/dwy.is/fullchain.pem; # managed by Certbot
      ssl_certificate_key /etc/letsencrypt/live/dwy.is/privkey.pem; # managed by Certbot
      include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    
      server_name autobase.dwy.is;
    
      add_header Access-Control-Allow-Origin *;
    
      location / {
        proxy_pass https://172.17.0.1:8082/;
      }
    }

    Getting a bit long now ... 📜 🙃

    New error:

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://autobase.dwy.is:8080/api/v1/projects?limit=999999999. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 502.

    Image
  6. nelsonic commented on Mar 25, 2025

    @nelsonic
    MemberAuthor
  7. nelsonic commented on Mar 25, 2025

    @nelsonic
    MemberAuthor

    Getting 502 Bad Gateway now: https://autobase.dwy.is:8080/
    Image

    Ah! I figured it out!! 🎉 The upstream is HTTP and I was attempting as HTTPS derp!

    The line:

        proxy_pass https://172.17.0.1:8082/;

    Needed to be:

        proxy_pass http://172.17.0.1:8082/;

    The proxy on the local system is http so isn't a security issue; what matters is that it's https over the net. 🔒

    Working now!

    Image

    https://autobase.dwy.is/clusters
    Image

    HTTPS 🔐 🎉

  8. moved this from More ToDo ThanCanEver Be Done to Done in Nelson's Liston Mar 25, 2025
  9. nelsonic commented on Mar 25, 2025

    @nelsonic
    MemberAuthor

    I have a lot of tabs/windows to close ... 😜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions