Zero trust tunnel giving 502 error for NGINX when TLS verification is on

What is the name of the domain?

batzbak.top

What is the error number?

502

What is the error message?

502 bad gateway

What is the issue you’re encountering

I configured Origin CA c ertificates and added them to a .pem file and a .key file on my origin server (NGINX). I point my NGINX conf to them. Unfortunately, when I leave TLS verify turned on, it gives me a 502 error, when leaving it off, it works as intended.

What steps have you taken to resolve the issue?

Turned off TLS verify

This is my config:

server {
    # Listen on port 443 for HTTPS
    listen 443 ssl;
    listen [::]:443 ssl;
    server_name subdomain.batzbak.top;

    # SSL certificates
    ssl_certificate /etc/ssl/certs/batzbak.top.pem;    # Path to your SSL certificate
    ssl_certificate_key /etc/ssl/private/batzbak.top.key; # Path to your SSL private key

    # Proxy settings to forward traffic to local server (e.g., localhost:5000)
    location / {
        proxy_pass http://ip:port;  
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;

        # WebSocket support (if applicable)
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

# Redirect HTTP traffic to HTTPS
server {
    listen 80;
    server_name *.batzbak.top batzbak.top;

    location / {
        return 301 https://$host$request_uri;  # Redirect all HTTP requests to HTTPS
    }
}```

Try this article here: Origin CA certificates | Cloudflare SSL/TLS docs