2024-05-18 23:53:03 +00:00
|
|
|
upstream {{ backendName }} {
|
|
|
|
least_conn;
|
|
|
|
{% for backend in backends %}
|
|
|
|
server {{ backend }};
|
|
|
|
{% endfor %}
|
|
|
|
}
|
2021-06-06 15:38:46 +00:00
|
|
|
server {
|
|
|
|
{% if allowNonSSL %}
|
2024-02-26 20:54:24 +00:00
|
|
|
# Non-SSL Traffic is allowed
|
|
|
|
listen {{ portHttp }};
|
|
|
|
listen [::]:{{ portHttp }};
|
2021-06-06 15:38:46 +00:00
|
|
|
{% endif %}
|
2024-02-26 20:54:24 +00:00
|
|
|
# SSL Traffic is allowed
|
|
|
|
listen {{ portHttps }} ssl;
|
|
|
|
listen [::]:{{ portHttps }} ssl;
|
|
|
|
server_name {{ serverName }};
|
|
|
|
access_log /var/log/bouncer/{{ name }}.access.log;
|
|
|
|
error_log /var/log/bouncer/{{ name }}.error.log;
|
2021-06-06 15:38:46 +00:00
|
|
|
|
2024-02-08 15:48:07 +00:00
|
|
|
{% if certType == 'TEMPORARY_CERT' %}
|
2024-02-26 20:54:24 +00:00
|
|
|
ssl_certificate /certs/example.crt;
|
|
|
|
ssl_certificate_key /certs/example.key;
|
2024-02-08 15:48:07 +00:00
|
|
|
{% elseif certType == 'GLOBAL_CERT' %}
|
2024-02-26 20:54:24 +00:00
|
|
|
ssl_certificate /certs/global.crt;
|
|
|
|
ssl_certificate_key /certs/global.key;
|
2024-02-08 15:48:07 +00:00
|
|
|
{% elseif certType == 'CUSTOM_CERT' %}
|
2024-02-26 20:54:24 +00:00
|
|
|
ssl_certificate /etc/nginx/sites-enabled/{{ customCertFile }};
|
|
|
|
ssl_certificate_key /etc/nginx/sites-enabled/{{ customCertKeyFile }};
|
2024-02-08 15:48:07 +00:00
|
|
|
{% elseif certType == 'LETSENCRYPT_CERT' %}
|
2024-02-26 20:54:24 +00:00
|
|
|
ssl_certificate /etc/letsencrypt/live/{{ name }}/fullchain.pem;
|
|
|
|
ssl_certificate_key /etc/letsencrypt/live/{{ name }}/privkey.pem;
|
2021-06-06 15:38:46 +00:00
|
|
|
{% endif %}
|
2024-02-26 20:54:24 +00:00
|
|
|
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
|
|
|
|
# ssl_ciphers HIGH:!aNULL:!MD5;
|
2021-06-06 15:38:46 +00:00
|
|
|
|
2022-06-15 09:34:07 +00:00
|
|
|
{% if allowLargePayloads %}
|
2023-02-07 14:26:44 +00:00
|
|
|
client_max_body_size 0;
|
2022-06-15 09:22:24 +00:00
|
|
|
{% endif %}
|
|
|
|
|
2021-06-06 15:38:46 +00:00
|
|
|
location / {
|
2024-01-25 10:41:42 +00:00
|
|
|
{% if hasHostOverride %}
|
2024-02-26 20:54:24 +00:00
|
|
|
proxy_set_header Host {{ hostOverride }};
|
2024-01-25 10:41:42 +00:00
|
|
|
{% else %}
|
2024-02-26 20:54:24 +00:00
|
|
|
proxy_set_header Host $host;
|
2024-01-25 10:41:42 +00:00
|
|
|
{% endif %}
|
2022-05-16 09:55:29 +00:00
|
|
|
|
2024-02-26 20:54:24 +00:00
|
|
|
# Server to send the request on to
|
2024-05-18 23:53:03 +00:00
|
|
|
proxy_pass "http://{{ backendName }}";
|
2024-02-26 20:54:24 +00:00
|
|
|
|
|
|
|
# Standard headers setting origin data
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
|
2023-01-09 14:57:00 +00:00
|
|
|
{% if hasAuth %}
|
2024-02-26 20:54:24 +00:00
|
|
|
# Http Basic Auth
|
|
|
|
auth_basic "closed site";
|
|
|
|
auth_basic_user_file sites-enabled/{{ authFile }};
|
2023-01-09 14:57:00 +00:00
|
|
|
{% endif %}
|
|
|
|
|
2022-06-15 09:22:24 +00:00
|
|
|
{% if allowWebsocketSupport %}
|
2022-05-16 09:55:29 +00:00
|
|
|
# WebSocket support
|
2024-02-26 20:54:24 +00:00
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection "Upgrade";
|
|
|
|
proxy_cache_bypass $http_upgrade;
|
|
|
|
proxy_buffering off;
|
|
|
|
proxy_set_header Origin "";
|
2022-06-15 09:22:24 +00:00
|
|
|
{% endif %}
|
2022-05-16 09:55:29 +00:00
|
|
|
|
2023-01-09 14:57:00 +00:00
|
|
|
{% if proxyTimeoutSeconds %}
|
2024-02-26 20:54:24 +00:00
|
|
|
# Proxy timeouts
|
|
|
|
proxy_read_timeout {{ proxyTimeoutSeconds }};
|
|
|
|
proxy_connect_timeout {{ proxyTimeoutSeconds }};
|
|
|
|
proxy_send_timeout {{ proxyTimeoutSeconds }};
|
2023-01-09 14:57:00 +00:00
|
|
|
{% endif %}
|
2024-01-25 11:37:06 +00:00
|
|
|
}
|
2022-06-18 23:23:47 +00:00
|
|
|
}
|
|
|
|
|
2021-06-06 15:38:46 +00:00
|
|
|
{% if not allowNonSSL %}
|
|
|
|
server {
|
2024-02-26 20:54:24 +00:00
|
|
|
# Redirect non-ssl to ssl
|
|
|
|
listen {{ portHttp }};
|
|
|
|
listen [::]:{{ portHttp }};
|
|
|
|
server_name {{ serverName }};
|
|
|
|
return 301 https://$host$request_uri;
|
2021-06-06 15:38:46 +00:00
|
|
|
}
|
2023-01-09 14:57:00 +00:00
|
|
|
{% endif %}
|