92 lines
3.8 KiB
Plaintext
92 lines
3.8 KiB
Plaintext
{% if USE_REVERSE_PROXY == "yes" +%}
|
|
|
|
{% if REVERSE_PROXY_INTERCEPT_ERRORS == "yes" +%}
|
|
proxy_intercept_errors on;
|
|
{% else +%}
|
|
proxy_intercept_errors off;
|
|
{% endif +%}
|
|
|
|
{% if USE_PROXY_CACHE == "yes" +%}
|
|
proxy_cache proxycache;
|
|
proxy_cache_methods {{ PROXY_CACHE_METHODS }};
|
|
proxy_cache_min_uses {{ PROXY_CACHE_MIN_USES }};
|
|
proxy_cache_key {{ PROXY_CACHE_KEY }};
|
|
proxy_no_cache {{ PROXY_NO_CACHE }};
|
|
proxy_cache_bypass {{ PROXY_CACHE_BYPASS }};
|
|
{% if PROXY_CACHE_VALID != "" +%}
|
|
{% for element in PROXY_CACHE_VALID.split(" ") +%}
|
|
proxy_cache_valid {{ element.split("=")[0] }} {{ element.split("=")[1] }};
|
|
{% endfor %}
|
|
add_header X-Proxy-Cache $upstream_cache_status;
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{% set counter = namespace(value=1) %}
|
|
{% for k, v in all.items() %}
|
|
{% if k.startswith("REVERSE_PROXY_URL") and v != "" +%}
|
|
{% set url = v %}
|
|
{% set host = all[k.replace("URL", "HOST")] if k.replace("URL", "HOST") in all else "" %}
|
|
{% set ws = all[k.replace("URL", "WS")] if k.replace("URL", "WS") in all else "" %}
|
|
{% set headers = all[k.replace("URL", "HEADERS")] if k.replace("URL", "HEADERS") in all else "" %}
|
|
{% set headers_client = all[k.replace("URL", "HEADERS_CLIENT")] if k.replace("URL", "HEADERS_CLIENT") in all else "" %}
|
|
{% set buffering = all[k.replace("URL", "BUFFERING")] if k.replace("URL", "BUFFERING") in all else "yes" %}
|
|
{% set keepalive = all[k.replace("URL", "KEEPALIVE")] if k.replace("URL", "KEEPALIVE") in all else "yes" %}
|
|
{% set auth_request = all[k.replace("URL", "AUTH_REQUEST")] if k.replace("URL", "AUTH_REQUEST") in all else "" %}
|
|
{% set auth_request_signin_url = all[k.replace("URL", "AUTH_REQUEST_SIGNIN_URL")] if k.replace("URL", "AUTH_REQUEST_SIGNIN_URL") in all else "" %}
|
|
{% set auth_request_sets = all[k.replace("URL", "AUTH_REQUEST_SET")] if k.replace("URL", "AUTH_REQUEST_SET") in all else "" %}
|
|
{% set connect_timeout = all[k.replace("URL", "CONNECT_TIMEOUT")] if k.replace("URL", "CONNECT_TIMEOUT") in all else "" %}
|
|
{% set read_timeout = all[k.replace("URL", "READ_TIMEOUT")] if k.replace("URL", "READ_TIMEOUT") in all else "" %}
|
|
{% set send_timeout = all[k.replace("URL", "SEND_TIMEOUT")] if k.replace("URL", "SEND_TIMEOUT") in all else "" %}
|
|
location {{ url }} {% raw %}{{% endraw +%}
|
|
etag off;
|
|
set $backend{{ counter.value }} "{{ host }}";
|
|
proxy_pass $backend{{ counter.value }};
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Protocol $scheme;
|
|
proxy_set_header X-Forwarded-Host $http_host;
|
|
{% if buffering == "yes" +%}
|
|
proxy_buffering on;
|
|
{% else +%}
|
|
proxy_buffering off;
|
|
{% endif %}
|
|
{% if ws == "yes" +%}
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection $connection_upgrade;
|
|
{% elif keepalive == "yes" +%}
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
{% endif %}
|
|
{% if auth_request != "" +%}
|
|
auth_request {{ auth_request }};
|
|
{% endif +%}
|
|
{% if auth_request_signin_url != "" +%}
|
|
error_page 401 =302 {{ auth_request_signin_url }};
|
|
{% endif +%}
|
|
{% if auth_request_sets != "" +%}
|
|
{% for auth_request_set in auth_request_sets.split(";") +%}
|
|
auth_request_set {{ auth_request_set }};
|
|
{% endfor +%}
|
|
{% endif +%}
|
|
{% if headers != "" +%}
|
|
{% for header in headers.split(";") +%}
|
|
proxy_set_header {{ header }};
|
|
{% endfor +%}
|
|
{% endif +%}
|
|
{% if headers_client != "" +%}
|
|
{% for header_client in headers_client.split(";") +%}
|
|
add_header {{ header_client }};
|
|
{% endfor +%}
|
|
{% endif +%}
|
|
{% raw %}}{% endraw %}
|
|
{% endif %}
|
|
proxy_connect_timeout {{ connect_timeout }};
|
|
proxy_read_timeout {{ read_timeout }};
|
|
proxy_send_timeout {{ send_timeout }};
|
|
{% set counter.value = counter.value + 1 %}
|
|
{% endfor %}
|
|
{% endif %} |