-
-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add PROMETHEUS_ALLOWLIST for specific firewall IP rules #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| "openrc", | ||
| "pidfile", | ||
| "policycoreutils", | ||
| "proto", | ||
| "respawn", | ||
| "restorecon", | ||
| "runlevels", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -597,19 +597,30 @@ systemd_disable() { | |
| firewall_rule() { | ||
| _firewall_path=$(command -v "$FIREWALL" 2>&1 || :) | ||
|
|
||
| _ips="" | ||
| if [ -n "$INSTALL_NODE_EXPORTER_FIREWALL_ALLOWLIST" ]; then | ||
| _ips=$(echo "$INSTALL_NODE_EXPORTER_FIREWALL_ALLOWLIST" | tr ',' ' ') | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe there's a better way to split the different IPs instead of relying on |
||
| fi | ||
|
|
||
| # shellcheck disable=SC2086 | ||
| set -- $_ips | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you use |
||
|
|
||
| case $FIREWALL in | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When the |
||
| firewall-cmd) | ||
| printf "%s\n%s\n" \ | ||
| "$_firewall_path --add-port=$NODE_EXPORTER_PORT/tcp --permanent" \ | ||
| "$_firewall_path --reload" | ||
| for _ip in "$@"; do | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not very familiar with configuring the various firewalls, so I need your help 🆘. More generally, does the same apply to the other firewall implementations? |
||
| printf "%s\n" "$_firewall_path --add-rich-rule=\"rule family='ipv4' source address='$_ip' port port='$NODE_EXPORTER_PORT' protocol='tcp' accept\" --permanent" | ||
| done | ||
| [ $# -gt 0 ] && printf "%s\n" "$_firewall_path --reload" | ||
| ;; | ||
| ufw) | ||
| printf "%s\n" \ | ||
| "$_firewall_path allow $NODE_EXPORTER_PORT/tcp" | ||
| for _ip in "$@"; do | ||
| printf "%s\n" "$_firewall_path allow from $_ip to any port $NODE_EXPORTER_PORT proto tcp" | ||
| done | ||
| ;; | ||
| iptables) | ||
| printf "%s\n" \ | ||
| "$_firewall_path -A INPUT -p tcp --dport $NODE_EXPORTER_PORT -m state --state NEW -j ACCEPT" | ||
| for _ip in "$@"; do | ||
| printf "%s\n" "$_firewall_path -A INPUT -s $_ip -p tcp --dport $NODE_EXPORTER_PORT -m state --state NEW -j ACCEPT" | ||
| done | ||
| ;; | ||
| *) fatal "Unknown firewall '$FIREWALL'" ;; | ||
| esac | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
printfinstead ofecho