Score:0

Nginx and Cloudflare Argo Tunnel - 502 Bad gateway

rw flag

I am using a Cloudflare Tunnel, along with a Nginx docker container, under the same tunnel network. I followed this guide to set up Nginx with Cloudflare. The goal is for me to be able to reach ports externally with HTTPS and without exposing the ports. The tunnel allows me to do both of those things but Nginx gives errors when I try to connect from my subdomain.

I need help changing my configuration to fix the errors. I am fine with removing SSL and HTTPS because the Tunnel is already HTTPS.

Nginx Config:

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

upstream supabase {
    server 0.0.0.0:3000;
}

upstream kong {
    server 0.0.0.0:8000;
}

server {
    listen       80;
    server_name  localhost, 0.0.0.0, api.globemedia.me;

    #access_log  /var/log/nginx/host.access.log  main;

    if ($host = api.domain.com) {
        return 301 https://$host$request_uri;
    } 
    return 404;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

server {
    listen [::]:443 ssl; 
    listen 443 ssl; 
    server_name  localhost, 0.0.0.0, api.example.com;

    ssl_session_cache    shared:SSL:10m;
    ssl_certificate ./fullchain.pem;
    ssl_certificate_key ./privatekey.pem;

    # REST API
    location ~ ^/rest/v1/(.*)$ {
        proxy_set_header Host $host;
        proxy_pass http://kong;
        proxy_redirect off;
    }

    # Authentication
    location ~ ^/auth/v1/(.*)$ {
        proxy_set_header Host $host;
        proxy_pass http://kong;
        proxy_redirect off;
    }

    # Realtime
    location ~ ^/realtime/v1/(.*)$ {
        proxy_redirect off;
        proxy_pass http://kong;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
        proxy_set_header Host $host;
    }
    
    # Studio
    location / {
        proxy_set_header Host $host;
        proxy_pass http://supabase;
        proxy_redirect off;
        proxy_set_header Upgrade $http_upgrade;
    }
}

Error Log:

2022/12/10 21:49:33 [notice] 1#1: signal 1 (SIGHUP) received from 139, reconfiguring
2022/12/10 21:49:33 [notice] 1#1: reconfiguring
2022/12/10 21:49:33 [notice] 1#1: using the "epoll" event method
2022/12/10 21:49:33 [notice] 1#1: start worker processes
2022/12/10 21:49:33 [notice] 1#1: start worker process 145
2022/12/10 21:49:33 [notice] 1#1: start worker process 146
2022/12/10 21:49:33 [notice] 1#1: start worker process 147
2022/12/10 21:49:33 [notice] 1#1: start worker process 148
2022/12/10 21:49:33 [notice] 123#123: gracefully shutting down
2022/12/10 21:49:33 [notice] 124#124: gracefully shutting down
2022/12/10 21:49:33 [notice] 125#125: gracefully shutting down
2022/12/10 21:49:33 [notice] 123#123: exiting
2022/12/10 21:49:33 [notice] 124#124: exiting
2022/12/10 21:49:33 [notice] 125#125: exiting
2022/12/10 21:49:33 [notice] 123#123: exit
2022/12/10 21:49:33 [notice] 124#124: exit
2022/12/10 21:49:33 [notice] 125#125: exit
2022/12/10 21:49:33 [notice] 126#126: gracefully shutting down
2022/12/10 21:49:33 [notice] 126#126: exiting
2022/12/10 21:49:33 [notice] 126#126: exit
2022/12/10 21:49:34 [notice] 1#1: signal 17 (SIGCHLD) received from 123
2022/12/10 21:49:34 [notice] 1#1: worker process 123 exited with code 0
2022/12/10 21:49:34 [notice] 1#1: worker process 124 exited with code 0
2022/12/10 21:49:34 [notice] 1#1: worker process 125 exited with code 0
2022/12/10 21:49:34 [notice] 1#1: worker process 126 exited with code 0
2022/12/10 21:49:34 [notice] 1#1: signal 29 (SIGIO) received
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.