351 lines
13 KiB
Django/Jinja
Executable file
351 lines
13 KiB
Django/Jinja
Executable file
# nginx configuration file
|
|
# inserts into http location
|
|
|
|
{% if app_config[app].USUAL_SETTINGS %}
|
|
{% for group in app_config[app].UPSTREAM_GROUPS %}
|
|
{% if group.ips | length > 0 %}
|
|
upstream secure{{ app_config[app].SID_NUMBERS[loop.index0] }}_{{ group.suffix }} {
|
|
{% for ip in group.ips %}
|
|
server {{ ip }}:443 weight=50;
|
|
{% endfor %}
|
|
keepalive 60;
|
|
keepalive_timeout 70s;
|
|
}
|
|
|
|
upstream unsecure{{ app_config[app].SID_NUMBERS[loop.index0] }}_{{ group.suffix }} {
|
|
{% for ip in group.ips %}
|
|
server {{ ip }}:80 weight=50;
|
|
{% endfor %}
|
|
keepalive 60;
|
|
keepalive_timeout 70s;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
server_name {{ app_config[app].SERVER_NAMES_FOR_APPS[loop.index0] }};
|
|
|
|
|
|
access_log /var/log/nginx/{{ app_config[app].SID_NUMBERS[loop.index0] }}_{{ group.suffix }}_access.log waf;
|
|
error_log /var/log/nginx/{{ app_config[app].SID_NUMBERS[loop.index0] }}_{{ group.suffix }}_error.log error;
|
|
|
|
|
|
set_real_ip_from 172.16.0.0/12;
|
|
real_ip_header X-Forwarded-For;
|
|
real_ip_recursive on;
|
|
|
|
|
|
server_tokens off;
|
|
sendfile on;
|
|
gzip on;
|
|
client_max_body_size 0;
|
|
large_client_header_buffers 4 128k;
|
|
|
|
|
|
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
|
|
proxy_http_version 1.1;
|
|
proxy_connect_timeout 3s;
|
|
proxy_busy_buffers_size 32k;
|
|
proxy_buffers 4 32k;
|
|
proxy_buffer_size 16k;
|
|
proxy_read_timeout 120s;
|
|
proxy_send_timeout 120s;
|
|
send_timeout 60s;
|
|
keepalive_timeout 75s;
|
|
keepalive_requests 1000;
|
|
resolver_timeout 30s;
|
|
|
|
|
|
#proxy_set_header X-Real-IP $remote_addr;
|
|
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Host $host;
|
|
proxy_pass_header Date;
|
|
proxy_pass_header Server;
|
|
|
|
|
|
location / {
|
|
proxy_pass http://unsecure{{ app_config[app].SID_NUMBERS[loop.index0] }}_{{ group.suffix }};
|
|
}
|
|
}
|
|
|
|
|
|
server {
|
|
listen 443;
|
|
server_name {{ app_config[app].SERVER_NAMES_FOR_APPS[loop.index0] }};
|
|
|
|
|
|
access_log /var/log/nginx/{{ app_config[app].SID_NUMBERS[loop.index0] }}_{{ group.suffix }}_access.log waf;
|
|
error_log /var/log/nginx/{{ app_config[app].SID_NUMBERS[loop.index0] }}_{{ group.suffix }}_error.log error;
|
|
|
|
|
|
proxy_ssl_server_name on;
|
|
proxy_ssl_name $host;
|
|
|
|
|
|
set_real_ip_from 172.16.0.0/12;
|
|
real_ip_header X-Forwarded-For;
|
|
real_ip_recursive on;
|
|
|
|
|
|
server_tokens off;
|
|
sendfile on;
|
|
gzip on;
|
|
client_max_body_size 0;
|
|
large_client_header_buffers 4 128k;
|
|
|
|
|
|
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
|
|
proxy_http_version 1.1;
|
|
proxy_connect_timeout 3s;
|
|
proxy_busy_buffers_size 32k;
|
|
proxy_buffers 4 32k;
|
|
proxy_buffer_size 16k;
|
|
proxy_read_timeout 120s;
|
|
proxy_send_timeout 120s;
|
|
send_timeout 60s;
|
|
keepalive_timeout 75s;
|
|
keepalive_requests 1000;
|
|
resolver_timeout 30s;
|
|
|
|
|
|
#proxy_set_header X-Real-IP $remote_addr;
|
|
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Host $host;
|
|
proxy_pass_header Date;
|
|
proxy_pass_header Server;
|
|
|
|
|
|
location / {
|
|
proxy_pass https://secure{{ app_config[app].SID_NUMBERS[loop.index0] }}_{{ group.suffix }};
|
|
|
|
}
|
|
|
|
}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
{% if app_config[app].CUSTOM_CONFIG_PTAF_NGINX_NEED %}
|
|
{% for group in app_config[app].UPSTREAM_GROUPS_CUSTOM %}
|
|
|
|
upstream secure{{ app_config[app].SID_NUMBERS_WITH_CUSTOM[loop.index0] }}_{{ group.suffix }} {
|
|
{% for ip in group.ips %}
|
|
server {{ ip }}:443 weight=50;
|
|
{% endfor %}
|
|
{% if app_config[app].CUSTOM_CONFIG_PTAF_NGINX_UPSTREAM_NEED %}
|
|
{{ app_config[app].CUSTOM_CONFIG_PTAF_NGINX_UPSTREAM[loop.index0] }}
|
|
{% else %}
|
|
keepalive 60;
|
|
keepalive_timeout 70s;
|
|
{% endif %}
|
|
}
|
|
|
|
|
|
upstream unsecure{{ app_config[app].SID_NUMBERS_WITH_CUSTOM[loop.index0] }}_{{ group.suffix }} {
|
|
{% for ip in group.ips %}
|
|
server {{ ip }}:80 weight=50;
|
|
{% endfor %}
|
|
{% if app_config[app].CUSTOM_CONFIG_PTAF_NGINX_UPSTREAM_NEED %}
|
|
{{ app_config[app].CUSTOM_CONFIG_PTAF_NGINX_UPSTREAM[loop.index0] }}
|
|
{% else %}
|
|
keepalive 60;
|
|
keepalive_timeout 70s;
|
|
{% endif %}
|
|
}
|
|
|
|
|
|
server {
|
|
listen 80;
|
|
server_name {{ app_config[app].SERVER_NAMES_FOR_CUSTOM_APPS[loop.index0] }};
|
|
|
|
|
|
access_log /var/log/nginx/{{ app_config[app].SID_NUMBERS_WITH_CUSTOM[loop.index0] }}_{{ group.suffix }}_access.log waf;
|
|
error_log /var/log/nginx/{{ app_config[app].SID_NUMBERS_WITH_CUSTOM[loop.index0] }}_{{ group.suffix }}_error.log error;
|
|
|
|
|
|
set_real_ip_from 172.16.0.0/12;
|
|
real_ip_header X-Forwarded-For;
|
|
real_ip_recursive on;
|
|
|
|
|
|
server_tokens off;
|
|
sendfile on;
|
|
gzip on;
|
|
client_max_body_size 0;
|
|
large_client_header_buffers 4 128k;
|
|
|
|
|
|
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
|
|
proxy_http_version 1.1;
|
|
proxy_connect_timeout 3s;
|
|
proxy_busy_buffers_size 32k;
|
|
proxy_buffers 4 32k;
|
|
proxy_buffer_size 16k;
|
|
proxy_read_timeout 120s;
|
|
proxy_send_timeout 120s;
|
|
send_timeout 60s;
|
|
keepalive_timeout 75s;
|
|
keepalive_requests 1000;
|
|
resolver_timeout 30s;
|
|
|
|
|
|
#proxy_set_header X-Real-IP $remote_addr;
|
|
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Host $host;
|
|
proxy_pass_header Date;
|
|
proxy_pass_header Server;
|
|
|
|
|
|
location / {
|
|
proxy_pass http://unsecure{{ app_config[app].SID_NUMBERS_WITH_CUSTOM[loop.index0] }}_{{ group.suffix }};
|
|
{{ app_config[app].CUSTOM_CONFIG_PTAF_NGINX[loop.index0] }}
|
|
}
|
|
}
|
|
|
|
|
|
server {
|
|
listen 443;
|
|
server_name {{ app_config[app].SERVER_NAMES_FOR_CUSTOM_APPS[loop.index0] }};
|
|
|
|
|
|
access_log /var/log/nginx/{{ app_config[app].SID_NUMBERS_WITH_CUSTOM[loop.index0] }}_{{ group.suffix }}_access.log waf;
|
|
error_log /var/log/nginx/{{ app_config[app].SID_NUMBERS_WITH_CUSTOM[loop.index0] }}_{{ group.suffix }}_error.log error;
|
|
|
|
|
|
proxy_ssl_server_name on;
|
|
proxy_ssl_name $host;
|
|
|
|
|
|
set_real_ip_from 172.16.0.0/12;
|
|
real_ip_header X-Forwarded-For;
|
|
real_ip_recursive on;
|
|
|
|
|
|
server_tokens off;
|
|
sendfile on;
|
|
gzip on;
|
|
client_max_body_size 0;
|
|
large_client_header_buffers 4 128k;
|
|
|
|
|
|
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
|
|
proxy_http_version 1.1;
|
|
proxy_connect_timeout 3s;
|
|
proxy_busy_buffers_size 32k;
|
|
proxy_buffers 4 32k;
|
|
proxy_buffer_size 16k;
|
|
proxy_read_timeout 120s;
|
|
proxy_send_timeout 120s;
|
|
send_timeout 60s;
|
|
keepalive_timeout 75s;
|
|
keepalive_requests 1000;
|
|
resolver_timeout 30s;
|
|
|
|
|
|
#proxy_set_header X-Real-IP $remote_addr;
|
|
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Host $host;
|
|
proxy_pass_header Date;
|
|
proxy_pass_header Server;
|
|
|
|
|
|
location / {
|
|
proxy_pass https://secure{{ app_config[app].SID_NUMBERS_WITH_CUSTOM[loop.index0] }}_{{ group.suffix }};
|
|
{{ app_config[app].CUSTOM_CONFIG_PTAF_NGINX[loop.index0] }}
|
|
}
|
|
{% if app_config[app].CUSTOM_LOCATIONS_NEED %}
|
|
{{ app_config[app].CUSTOM_LOCATIONS_PTAF_NGINX[loop.index0] }}
|
|
{% endif %}
|
|
}
|
|
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
{% if app_config[app].CUSTOM_PORTS_NEED %}
|
|
{% for group in app_config[app].UPSTREAM_GROUPS_CUSTOM_PORTS %}
|
|
{% set outer_index = loop.index0 %}
|
|
|
|
upstream secure{{ app_config[app].SID_NUMBERS_WITH_CUSTOM_PORTS[loop.index0] }}_{{ group.suffix }}_{{ app_config[app].CUSTOM_PORTS[loop.index0] }} {
|
|
{% for ip in group.ips %}
|
|
server {{ ip }}:{{ app_config[app].CUSTOM_PORTS[outer_index] }} weight=50;
|
|
{% endfor %}
|
|
{% if app_config[app].CUSTOM_CONFIG_PTAF_NGINX_UPSTREAM_NEED_WITH_CUSTOM_PORTS %}
|
|
{{ app_config[app].CUSTOM_CONFIG_PTAF_NGINX_UPSTREAM_WITH_CUSTOM_PORTS[loop.index0] }}
|
|
{% else %}
|
|
keepalive 60;
|
|
keepalive_timeout 70s;
|
|
{% endif %}
|
|
}
|
|
|
|
server {
|
|
{% if app_config[app].CUSTOM_PORTS_NEED == true %}
|
|
{% if app_config[app].CUSTOM_CONFIG_ANGIE_NEED == false %}
|
|
listen {{ finded_port | int + (((app_config[app].CONTAINER_NUMBERS | int + 9) // 10 * 10) * (app_config[app].SID_NUMBERS | length) + (app_config[app].CONTAINER_NUMBERS | int + 9) // 10 * 10) + item + loop.index0 * ((app_config[app].CONTAINER_NUMBERS | int + 9) // 10 * 10) }};
|
|
{% else %}
|
|
listen {{ finded_port | int + (finded_port | int + (((app_config[app].CONTAINER_NUMBERS | int + 9) // 10 * 10) * (app_config[app].SID_NUMBERS | length) + (app_config[app].CONTAINER_NUMBERS | int + 9) // 10 * 10) + item + loop.index0 * ((app_config[app].CONTAINER_NUMBERS | int + 9) // 10 * 10)) }};
|
|
{% endif %}
|
|
{% endif %}
|
|
server_name {{ app_config[app].SERVER_NAMES_FOR_CUSTOM_APPS_PORTS[loop.index0] }};
|
|
|
|
|
|
access_log /var/log/nginx/{{ app_config[app].SID_NUMBERS_WITH_CUSTOM_PORTS[loop.index0] }}_{{ group.suffix }}_access.log waf;
|
|
error_log /var/log/nginx/{{ app_config[app].SID_NUMBERS_WITH_CUSTOM_PORTS[loop.index0] }}_{{ group.suffix }}_error.log error;
|
|
|
|
|
|
proxy_ssl_server_name on;
|
|
proxy_ssl_name $host;
|
|
|
|
|
|
set_real_ip_from 172.16.0.0/12;
|
|
real_ip_header X-Forwarded-For;
|
|
real_ip_recursive on;
|
|
|
|
|
|
server_tokens off;
|
|
sendfile on;
|
|
gzip on;
|
|
client_max_body_size 0;
|
|
large_client_header_buffers 4 128k;
|
|
|
|
|
|
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
|
|
proxy_http_version 1.1;
|
|
proxy_connect_timeout 3s;
|
|
proxy_busy_buffers_size 32k;
|
|
proxy_buffers 4 32k;
|
|
proxy_buffer_size 16k;
|
|
proxy_read_timeout 120s;
|
|
proxy_send_timeout 120s;
|
|
send_timeout 60s;
|
|
keepalive_timeout 75s;
|
|
keepalive_requests 1000;
|
|
resolver_timeout 30s;
|
|
|
|
|
|
#proxy_set_header X-Real-IP $remote_addr;
|
|
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Connection "upgrade";
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Host $host;
|
|
proxy_pass_header Date;
|
|
proxy_pass_header Server;
|
|
|
|
|
|
location / {
|
|
proxy_pass https://secure{{ app_config[app].SID_NUMBERS_WITH_CUSTOM_PORTS[loop.index0] }}_{{ group.suffix }}_{{ app_config[app].CUSTOM_PORTS[loop.index0] }};
|
|
{% if app_config[app].CUSTOM_CONFIG_PTAF_NGINX_NEED_WITH_CUSTOM_PORTS%}
|
|
{{ app_config[app].CUSTOM_CONFIG_PTAF_NGINX[loop.index0] }}
|
|
{% endif %}
|
|
}
|
|
|
|
}
|
|
|
|
{% endfor %}
|
|
{% endif %}
|