2025-08-01 11:14:34 +03:00
|
|
|
{{ $proxy_settings := "proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_set_header Host $http_host; proxy_set_header X-Request-Start $msec;" }}
|
|
|
|
{{ $gzip_settings := "gzip on; gzip_min_length 1100; gzip_buffers 4 32k; gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml; gzip_vary on; gzip_comp_level 6;" }}
|
2024-04-07 13:39:37 -03:00
|
|
|
|
2025-08-01 11:14:34 +03:00
|
|
|
{{ range $port_map := .PROXY_PORT_MAP | split " " }}
|
|
|
|
{{ $port_map_list := $port_map | split ":" }}
|
|
|
|
{{ $scheme := index $port_map_list 0 }}
|
|
|
|
{{ $listen_port := index $port_map_list 1 }}
|
|
|
|
{{ $upstream_port := index $port_map_list 2 }}
|
2024-12-17 20:14:01 +03:00
|
|
|
|
2025-07-31 18:55:59 +03:00
|
|
|
server {
|
2025-08-01 11:14:34 +03:00
|
|
|
{{ if eq $scheme "http" }}
|
|
|
|
listen [::]:{{ $listen_port }};
|
|
|
|
listen {{ $listen_port }};
|
|
|
|
server_name {{ $.NOSSL_SERVER_NAME }};
|
|
|
|
|
|
|
|
# Redirect HTTP to HTTPS
|
|
|
|
return 301 https://$server_name$request_uri;
|
|
|
|
|
|
|
|
{{ else if eq $scheme "https" }}
|
|
|
|
listen [::]:{{ $listen_port }} ssl http2;
|
|
|
|
listen {{ $listen_port }} ssl http2;
|
|
|
|
server_name {{ $.NOSSL_SERVER_NAME }};
|
|
|
|
ssl_certificate {{ $.APP_SSL_PATH }}/server.crt;
|
|
|
|
ssl_certificate_key {{ $.APP_SSL_PATH }}/server.key;
|
|
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
ssl_prefer_server_ciphers off;
|
|
|
|
|
|
|
|
keepalive_timeout 70;
|
|
|
|
keepalive_requests 500;
|
|
|
|
proxy_read_timeout 3600;
|
|
|
|
limit_conn addr 10000;
|
|
|
|
client_max_body_size 100M;
|
|
|
|
{{ end }}
|
2025-08-01 10:41:10 +03:00
|
|
|
|
|
|
|
|
|
|
|
location / {
|
2025-08-01 11:14:34 +03:00
|
|
|
proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
|
|
|
|
{{ $proxy_settings }}
|
|
|
|
{{ $gzip_settings }}
|
2025-07-31 18:55:59 +03:00
|
|
|
|
2025-08-01 11:55:37 +03:00
|
|
|
# Disable caching for GraphQL API
|
|
|
|
proxy_cache off;
|
|
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
|
|
add_header Pragma "no-cache";
|
|
|
|
add_header Expires "0";
|
2025-08-01 10:41:10 +03:00
|
|
|
|
2025-08-01 11:14:34 +03:00
|
|
|
# Connections and request limits increase (bad for DDos)
|
|
|
|
limit_req zone=req_zone burst=10 nodelay;
|
2023-10-09 23:47:18 +03:00
|
|
|
}
|
|
|
|
|
2025-08-01 11:14:34 +03:00
|
|
|
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
|
|
|
|
proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
|
|
|
|
expires 30d;
|
|
|
|
add_header Cache-Control "public, no-transform";
|
2024-02-27 06:05:01 -03:00
|
|
|
}
|
|
|
|
|
2025-07-31 18:55:59 +03:00
|
|
|
include {{ $.DOKKU_ROOT }}/{{ $.APP }}/nginx.conf.d/*.conf;
|
2023-10-09 23:47:18 +03:00
|
|
|
}
|
2025-08-01 11:14:34 +03:00
|
|
|
{{ end }}
|
|
|
|
|
2024-12-20 14:35:59 -03:00
|
|
|
|
2023-10-09 23:47:18 +03:00
|
|
|
{{ range $upstream_port := $.PROXY_UPSTREAM_PORTS | split " " }}
|
|
|
|
upstream {{ $.APP }}-{{ $upstream_port }} {
|
2025-07-31 18:55:59 +03:00
|
|
|
{{ range $listeners := $.DOKKU_APP_WEB_LISTENERS | split " " }}
|
|
|
|
{{ $listener_list := $listeners | split ":" }}
|
|
|
|
{{ $listener_ip := index $listener_list 0 }}
|
|
|
|
{{ $listener_port := index $listener_list 1 }}
|
|
|
|
server {{ $listener_ip }}:{{ $upstream_port }};
|
|
|
|
{{ end }}
|
2023-10-10 07:48:33 -03:00
|
|
|
}
|
2024-01-11 19:52:10 +03:00
|
|
|
{{ end }}
|