Skip to content

Commit 32491cf

Browse files
authored
fix: NGINX set_real_ip_from directive should be a list (#559)
1 parent 88a38b0 commit 32491cf

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ BUG FIXES:
1414
- Correct cleanup error when `nginx_config_cleanup_paths` is not defined.
1515
- Disable check_mode for validation task `jinja2_version`.
1616
- The default PID path has changed as of NGINX 1.27.5 and 1.28.0.
17+
- NGINX `set_real_ip_from` directive template parameter should be a list.
1718

1819
TESTS:
1920

molecule/complete_plus/converge.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@
315315
- value: '"~jndi:ldap"'
316316
new_value: 1
317317
realip:
318-
set_real_ip_from: 0.0.0.0
318+
set_real_ip_from:
319+
- 0.0.0.0
319320
real_ip_header: X-Real-IP
320321
real_ip_recursive: false
321322
rewrite:

templates/http/modules.j2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,12 @@ mirror_request_body {{ mirror['request_body'] | ternary('on', 'off') }};
254254

255255
{# NGINX HTTP RealIP -- ngx_http_realip_module #}
256256
{% macro realip(realip) %}
257-
{% if realip['set_real_ip_from'] is defined %}
257+
{% if realip['set_real_ip_from'] is defined and realip['set_real_ip_from'] is not mapping %}
258+
{% for set_real_ip_from in realip['set_real_ip_from'] if realip['set_real_ip_from'] is not string %}
259+
set_real_ip_from {{ set_real_ip_from }};
260+
{% else %}
258261
set_real_ip_from {{ realip['set_real_ip_from'] }};
262+
{% endfor %}
259263
{% endif %}
260264
{% if realip['real_ip_header'] is defined %}
261265
real_ip_header {{ realip['real_ip_header'] }};

0 commit comments

Comments
 (0)