Skip to content

Commit

Permalink
Add environment variable to set proxy bind address (#293)
Browse files Browse the repository at this point in the history
This patch adds the environment variable PROXY_BIND which
can be optionally set to override the default that binds
to "*".

Binding on all addresses may inadvertently expose the proxy
service when run on a node that also has public interfaces
such as a bare metal openstack infrastructure node, or a
network node.

Co-authored-by: Jonathan Rosser <[email protected]>
  • Loading branch information
jrosser and Jonathan Rosser authored Mar 7, 2024
1 parent 50a2c27 commit f896818
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions magnum_cluster_api/proxy/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self):
self.haproxy_port = utils.find_free_port(
port_hint=int(os.getenv("PROXY_PORT", 0))
)
self.haproxy_bind = os.getenv("PROXY_BIND", "*")
self.haproxy_pid = None

def periodic_tasks(self, context, raise_on_error=False):
Expand All @@ -55,6 +56,7 @@ def _sync_haproxy(self, proxied_clusters: list):
config = self.template.render(
pid_file=CONF.proxy.haproxy_pid_path,
port=self.haproxy_port,
bind=self.haproxy_bind,
clusters=proxied_clusters,
)

Expand Down
2 changes: 1 addition & 1 deletion magnum_cluster_api/proxy/templates/haproxy.cfg.j2
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defaults
timeout server 10s

frontend magnum
bind *:{{ port }}
bind {{ bind }}:{{ port }}
tcp-request inspect-delay 5s
tcp-request content accept if { req.ssl_hello_type 1 }
use_backend %[req.ssl_sni,lower]
Expand Down

0 comments on commit f896818

Please sign in to comment.