Skip to content

Commit d19a0c9

Browse files
committed
fix: set proxy server templates to listen to defined public port
The `port_public` option introduced in the following commit but never used in template creation while it's really usful. https://github.com/sitewards/ansible-role-prometheus-proxy/blob/adhoc_fix_port_clash/defaults/main.yml#L12-L15 The problem with current approach is we only can configure reverse proxy to use the same port for public listening and internal reversing and it's not possible to revese traffic to a different internal port if needed. The new approach can cover both possible cases. Reversing traffic to a different port and in case port must be the same, we still able to define the same port number in config file.
1 parent 833b136 commit d19a0c9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

templates/etc/apache2/sites-enabled/template.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{{ ansible_managed | comment }}
22

33
{% for ip in ansible_all_ipv4_addresses %}
4-
Listen {{ ip }}:{{ item.port }}
4+
Listen {{ ip }}:{{ item.port_public }}
55

6-
<VirtualHost {{ ip }}:{{ item.port }}>
6+
<VirtualHost {{ ip }}:{{ item.port_public }}>
77
ProxyPreserveHost On
88

99
<Location "/">
@@ -16,4 +16,4 @@ Listen {{ ip }}:{{ item.port }}
1616
</Location>
1717

1818
</VirtualHost>
19-
{% endfor %}
19+
{% endfor %}

templates/etc/nginx/sites-enabled/template.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
server {
44
{% for ip in ansible_all_ipv4_addresses %}
5-
listen {{ ip }}:{{ item.port }}{% if nginx_prometheus_tls_certificate_path is defined %} ssl http2{% endif %};
5+
listen {{ ip }}:{{ item.port_public }}{% if nginx_prometheus_tls_certificate_path is defined %} ssl http2{% endif %};
66
{% endfor %}
77

88
## We use "_" as a dirty trick to achieve catch-all behavior. See http://nginx.org/en/docs/http/server_names.html

0 commit comments

Comments
 (0)