Skip to content
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

Allow service-specific bind_addresses #82

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ If you do not list any default servers, no proxy will be created. The
This section is its own hash, which should contain the following keys:

* `port`: the port (on localhost) where HAProxy will listen for connections to the service. If this is omitted, only a backend stanza (and no frontend stanza) will be generated for this service; you'll need to get traffic to your service yourself via the `shared_frontend` or manual frontends in `extra_sections`
* `bind_address`: the IP address the frontend will listen on. This will override a bind_address specified globally below.
* `server_port_override`: the port that discovered servers listen on; you should specify this if your discovery mechanism only discovers names or addresses (like the DNS watcher). If the discovery method discovers a port along with hostnames (like the zookeeper watcher) this option may be left out, but will be used in preference if given.
* `server_options`: the haproxy options for each `server` line of the service in HAProxy config; it may be left out.
* `frontend`: additional lines passed to the HAProxy config in the `frontend` stanza of this service
Expand Down
4 changes: 3 additions & 1 deletion lib/synapse/haproxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,12 @@ def generate_frontend_stanza(watcher, config)
return []
end

bind_address = (watcher.haproxy['bind_address'] || @opts['bind_address'] || 'localhost')

stanza = [
"\nfrontend #{watcher.name}",
config.map {|c| "\t#{c}"},
"\tbind #{@opts['bind_address'] || 'localhost'}:#{watcher.haproxy['port']}",
"\tbind #{bind_address}:#{watcher.haproxy['port']}",
"\tdefault_backend #{watcher.name}"
]
end
Expand Down