I am using Cloudflare as a proxy for all of my containers. I’d like to be able to block all non-Cloudflare IP’s. In a non-Docker system, I would use UFW and deny all with a script running to pull the IP list from cloudflare.com/ips to whitelist 443 incoming.
Given docker messes up your ability to use UFW and IPTables, what method would you recommend to block traffic. I know Swag has fail2ban built in, but I haven’t come up with a method to use it to restrict to Cloudflare and update the IP ranges regularly.
Create the .crt file (I just created it at the base of my SWAG config folder) you can get from the above link. Then, in the ssl.conf file, add the following line:
I added it just after the Certificates section and the Diffie-Hellman Paramters sections.
Now, using the cloudflare instructions, turn on Authenticated Origin Pulls. Now Cloudflare handshakes with their key and your Swag. If you attempt to contact your swag server bypassing the Cloudflare proxy, you get a 400 error.
This is a bit over my head, so hopefully my question makes sense.
My NAT doesn’t support hairpinning, so I have added CNAME records to my LAN’s DNS server so LAN clients can access the Swag services by their public hostnames, so they use HTTPS. If I understand this correctly that wouldn’t work anymore, since my LAN client wouldn’t have a Cloudflare client cert obviously.
Is there a way to do this where clients on the same network as the SWAG server are allowed access?