Skip to content

Cloudflare

Conor McKnight edited this page Sep 7, 2025 · 12 revisions

Cloudflare

The following is only needed if you are using Cloudflare as a proxy service, If you use it as DNS only you do not need to do any of this.

Modify the following line : https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/blob/master/lua/anti_ddos_challenge.lua

To this :

localized.remote_addr = "auto"

Optional to avoid Issues with Cloudflare page rules

Cache Everything Page rule

So Cloudflare allows you to Cache pages on their CDN the header status in requests will say

CF-Cache-Status : HIT

If you use page rules to Cache pages of your site make sure this setting localized.javascript_REQUEST_TYPE is set to value 2. By default it should be 2.

https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/blob/master/lua/anti_ddos_challenge.lua

--[[
The type of javascript based pingback authentication method to use if it should be GET or POST or can switch between both making it as dynamic as possible.
1 = GET
2 = POST
3 = DYNAMIC
]]
localized.javascript_REQUEST_TYPE = 2 --Default 2

Because Cloudflare caches GET requests it will cache the Anti-DDoS page output instead of what you intend to be Cached so to fix it we make it a POST request since Cloudflare does not Cache those.

Clone this wiki locally