Help with Cloudflare configuration after and during DDoS attack

Aditional info.

With this setup mentioned, sometimes it loads the whole web fine, and sometimes it loads the web but it gives me my internal error 508 (Resource Limit reached)

When it doesn’t load it gives me an error Bad gateway Error code 502
or SSL handshake failed Error code 525

It seems that it is because of the DDoS attack?