502 bad gateway, randomly

I have setup a proxied A record to my home server (machine is sufficiently beefy).
The server runs dockerized NGINX Reverse proxy and a dockerized webserver.

Very randomly, visitors to my website get a cloudflare 502 and it’s gone when refreshing.

What can I do to debug?
Also, what is the best practise for my proxy headers?

server {
    listen 443;
    listen [::]:443 ssl http2;
    server_name mysite.com;

    # all ssl related config moved to ssl.conf
    ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem;

    server_tokens off;

    location / {
        proxy_pass         http://mysite_container:80/;
        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-Host $server_name;
        proxy_set_header   X-Forwarded-Proto https;

        proxy_read_timeout  1200s;

        client_max_body_size 0;

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.