One simple approach I take to solve this issue is by whitelisting (using ufw/VPS firewall) Github's webhook IPs listed at https://api.github.com/meta
This works flawlessly while keeping your CI server secure.
One simple approach I take to solve this issue is by whitelisting (using ufw/VPS firewall) Github's webhook IPs listed at https://api.github.com/meta
This works flawlessly while keeping your CI server secure.
The current list has 4 IPv4 IP range and upon checking my server firewall(last updated 3 years ago), I can see I have the first 3 entries in there.
So in the last 3 years, Github has added 1 new IP range which is missing from my server but even then, no webhook call has ever failed to my CI server.
As a precaution I just updated my server firewall right now.
You could of course write a cron script to regularly check Github hooks IPs and update firewall if Github changes it's webhooks IPs.
> You could of course write a cron script to regularly check Github hooks IPs and update firewall if Github changes it's webhooks IPs.
This is way easier and simpler than any other solution. It will be a mere 6 line script.
ipset create ghwebhooks hash:net
iptables -A INPUT -m set --match-set ghwebhooks src -m tcp --dport 443 -j ALLOW
# in /etc/cron.daily
ipset add ...
ipset del ...
ipset list ...
ipset save >/etc/ipset.conf