{% set workers = salt['pillar.get']('profile:matrix:workers') %} {% for app, types in workers.items() %} {% for type in types %} {%- if type.get('rest') is mapping %} {%- for uri in type.get('rest') %} location ~ {{ uri }} { proxy_pass http://{{ app }}_{{ loop.index }}$request_uri; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; } {% endfor %} {% endif %} {% endfor %} {% endfor %}