feat: add PROMETHEUS_ALLOWLIST for specific firewall IP rules - #102
feat: add PROMETHEUS_ALLOWLIST for specific firewall IP rules#102nfrozi wants to merge 3 commits into
Conversation
nfrozi
commented
Jul 15, 2026
- Add logic in install.sh to apply firewall rules only to specific IPs/CIDRs if PROMETHEUS_ALLOWLIST is defined.
- Update README.md environment variables table.
- Add 'proto' to cspell.json to fix spelling check failure.
|
Hey, thanks for your contribution! I have a few comments:
What do you think? 🤗 |
|
Thank you for the feedback.
|
|
@nfrozi |
| fi | ||
|
|
||
| # shellcheck disable=SC2086 | ||
| set -- $_ips |
There was a problem hiding this comment.
Why do you use set -- $_ips instead of working with $_ips directly?
|
|
||
| _ips="" | ||
| if [ -n "$INSTALL_NODE_EXPORTER_FIREWALL_ALLOWLIST" ]; then | ||
| _ips=$(echo "$INSTALL_NODE_EXPORTER_FIREWALL_ALLOWLIST" | tr ',' ' ') |
There was a problem hiding this comment.
Use printf instead of echo
|
|
||
| _ips="" | ||
| if [ -n "$INSTALL_NODE_EXPORTER_FIREWALL_ALLOWLIST" ]; then | ||
| _ips=$(echo "$INSTALL_NODE_EXPORTER_FIREWALL_ALLOWLIST" | tr ',' ' ') |
There was a problem hiding this comment.
Maybe there's a better way to split the different IPs instead of relying on tr? Perhaps we can reuse something that's already used elsewhere and avoid introducing a new dependency on tr?
| printf "%s\n%s\n" \ | ||
| "$_firewall_path --add-port=$NODE_EXPORTER_PORT/tcp --permanent" \ | ||
| "$_firewall_path --reload" | ||
| for _ip in "$@"; do |
There was a problem hiding this comment.
I'm not very familiar with configuring the various firewalls, so I need your help 🆘.
What happens if the IP address is an IPv6 rather than an IPv4?
Do we need to detect the IP version and pass different arguments accordingly, or does firewall-cmd handle that automatically?
More generally, does the same apply to the other firewall implementations?
Are they IP-version agnostic, or do we need to explicitly specify whether an address is IPv4 or IPv6? Thanks 🙌
| # shellcheck disable=SC2086 | ||
| set -- $_ips | ||
|
|
||
| case $FIREWALL in |
There was a problem hiding this comment.
When the IP list is empty, no firewall rules are added.
This is a regression compared to the previous behavior.
|
@nfrozi Sorry for the late reply 😥🙌 |