Skip to content

Commit

Permalink
fix: set proxy server templates to listen to defined public port
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
omidy1 committed May 9, 2023
1 parent 833b136 commit d19a0c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions templates/etc/apache2/sites-enabled/template.conf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{ ansible_managed | comment }}

{% for ip in ansible_all_ipv4_addresses %}
Listen {{ ip }}:{{ item.port }}
Listen {{ ip }}:{{ item.port_public }}

<VirtualHost {{ ip }}:{{ item.port }}>
<VirtualHost {{ ip }}:{{ item.port_public }}>
ProxyPreserveHost On

<Location "/">
Expand All @@ -16,4 +16,4 @@ Listen {{ ip }}:{{ item.port }}
</Location>

</VirtualHost>
{% endfor %}
{% endfor %}
2 changes: 1 addition & 1 deletion templates/etc/nginx/sites-enabled/template.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

server {
{% for ip in ansible_all_ipv4_addresses %}
listen {{ ip }}:{{ item.port }}{% if nginx_prometheus_tls_certificate_path is defined %} ssl http2{% endif %};
listen {{ ip }}:{{ item.port_public }}{% if nginx_prometheus_tls_certificate_path is defined %} ssl http2{% endif %};
{% endfor %}

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

0 comments on commit d19a0c9

Please sign in to comment.