Need help with Tunnel, Raspberry Pi 5 and Nginx. 502 Bad Gateway.
So I have been trying to get my website up and tunneled through cloudflare, I am using Nginx webserver on a raspberry pi 5. I can type in the device IP and find the page I want to serve, the tunnel in cloudflare says "healthy".. But when I type in my domain in the search bar, I get an error. I don't really know if its ngnix, but its listening to port 443 and cloudflare is forcing ssl so ? I think its my cloudflare configuration. I have tried to put in my public IP in the URL path in cloudlare, ive tried the pi's IP with different ports, i now have localhost in there and none of it works.
3 Replies
Bad Gateway means your tunnel (cloudflared ) can't connect to the origin service. You can check tunnel logs via
sudo journalctl -u cloudflared -f --lines=100
if on systemd linux, send request and look for errors. However, there's a more glaring issue with your config, you're saying your origin service is HTTPS localhost on 80. That doesn't make a whole lot of sense, https is typically 443.
From the pi, try curl http://127.0.0.1 -vvv
and/or curl https://127.0.0.1 -k -vvv
If http://127.0.0.1
, works, select http with the value 127.0.0.1, if https://127.0.0.1 works, same value but select https.
If you don't specify the port, it'll use the default (80 for http, 443 for https). You additionally don't need to worry about the security of http when connecting to a local origin service, since it's just the cloudflared service on the same machine connecting to it. If none of that works, show output of cloudflared logs on sending a requestI feel so dumb.. I tried to change the listening port, everything. idk. I changed that A LOT.... and never got the right configuration, and you saved my life. thank you thank you thank you thank you
i just needed to change it to http, not https.. I thought it would be insecure if I did that so I just didnt
http is secure on localhost