Set X-Forwarded-For only for requests from Cloudflare

This commit is contained in:
deflax 2025-02-06 20:50:32 +02:00
parent f7d13e1cf0
commit 4bf5e8f63a

View file

@ -47,6 +47,11 @@ frontend web
http-request set-header X-Url-Scheme https
http-request set-header Host %[ssl_fc_sni]
# Set X-Forwarded-For only for requests from Cloudflare
acl from_cf src -f /usr/local/etc/haproxy/cloudflare_ips.lst
acl cf_ip_hdr req.hdr(CF-Connecting-IP) -m found
http-request set-header X-Forwarded-For %[req.hdr(CF-Connecting-IP)] if from_cf cf_ip_hdr
# CORS
http-response set-header Access-Control-Allow-Origin "*"
http-response set-header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization, JSNLog-RequestId, activityId, applicationId, applicationUserId, channelId, senderId, sessionId"