From 3b10c6f6e8711270d6a461958f90b1acd7b03e77 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:03:20 -0300 Subject: [PATCH 01/11] feat: + to nginx.sigill config for /connect custom location --- nginx.conf.sigil | 111 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 76 insertions(+), 35 deletions(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index 35549b2..7168104 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -1,15 +1,56 @@ -{{ $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;" }} +# Proxy settings +{{ $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;" }} -{{ $cors_headers_options := "if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; }" }} -{{ $cors_headers_post := "if ($request_method = 'POST') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; add_header 'Access-Control-Allow-Credentials' 'true' always; }" }} -{{ $cors_headers_get := "if ($request_method = 'GET') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; add_header 'Access-Control-Allow-Credentials' 'true' always; }" }} +# GZIP settings +{{ $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;" }} +# CORS headers based on request methods +{{ $cors_headers_options := " +if ($request_method = 'OPTIONS') { + add_header 'Access-Control-Allow-Origin' '$allow_origin' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; + add_header 'Access-Control-Allow-Credentials' 'true'; + add_header 'Access-Control-Max-Age' 1728000; + add_header 'Content-Type' 'text/plain; charset=utf-8'; + add_header 'Content-Length' 0; + return 204; +}" }} + +{{ $cors_headers_post := " +if ($request_method = 'POST') { + add_header 'Access-Control-Allow-Origin' '$allow_origin' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; + add_header 'Access-Control-Allow-Credentials' 'true' always; +}" }} + +{{ $cors_headers_get := " +if ($request_method = 'GET') { + add_header 'Access-Control-Allow-Origin' '$allow_origin' always; + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; + add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; + add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; + add_header 'Access-Control-Allow-Credentials' 'true' always; +}" }} + +# Mapping for allowed origins map $http_origin $allow_origin { ~^https?:\/\/((.*\.)?localhost(:\d+)?|discoursio-webapp(-(.*))?\.vercel\.app|(.*\.)?discours\.io)$ $http_origin; default ""; } +# Server block setup {{ range $port_map := .PROXY_PORT_MAP | split " " }} {{ $port_map_list := $port_map | split ":" }} {{ $scheme := index $port_map_list 0 }} @@ -17,30 +58,29 @@ map $http_origin $allow_origin { {{ $upstream_port := index $port_map_list 2 }} server { + # HTTP/HTTPS settings {{ if eq $scheme "http" }} - listen [::]:{{ $listen_port }}; - listen {{ $listen_port }}; - server_name {{ $.NOSSL_SERVER_NAME }}; - access_log /var/log/nginx/{{ $.APP }}-access.log; - error_log /var/log/nginx/{{ $.APP }}-error.log; - + listen [::]:{{ $listen_port }}; + listen {{ $listen_port }}; + server_name {{ $.NOSSL_SERVER_NAME }}; + access_log /var/log/nginx/{{ $.APP }}-access.log; + error_log /var/log/nginx/{{ $.APP }}-error.log; {{ else if eq $scheme "https" }} - listen [::]:{{ $listen_port }} ssl http2; - listen {{ $listen_port }} ssl http2; - server_name {{ $.NOSSL_SERVER_NAME }}; - access_log /var/log/nginx/{{ $.APP }}-access.log; - error_log /var/log/nginx/{{ $.APP }}-error.log; - 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; + listen [::]:{{ $listen_port }} ssl http2; + listen {{ $listen_port }} ssl http2; + server_name {{ $.NOSSL_SERVER_NAME }}; + access_log /var/log/nginx/{{ $.APP }}-access.log; + error_log /var/log/nginx/{{ $.APP }}-error.log; + 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; {{ end }} - + # Default location block location / { - proxy_pass http://{{ $.APP }}-{{ $upstream_port }}; + proxy_pass http://{{ $.APP }}-{{ $upstream_port }}; {{ $proxy_settings }} {{ $gzip_settings }} {{ $cors_headers_options }} @@ -51,18 +91,20 @@ server { # Custom location block for /connect location /connect { proxy_pass http://presence-8080; - {{ $cors_headers_options }} - {{ $cors_headers_post }} - {{ $cors_headers_get }} - + {{ $proxy_settings }} + {{ $cors_headers_options }} + {{ $cors_headers_post }} + {{ $cors_headers_get }} } + # Cache settings for static assets location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { - expires 30d; # This means that the client can cache these resources for 30 days. - add_header Cache-Control "public, no-transform"; + expires 30d; + add_header Cache-Control "public, no-transform"; } - + # Error pages + error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 /400-error.html; location /400-error.html { root /var/lib/dokku/data/nginx-vhosts/dokku-errors; @@ -87,12 +129,11 @@ server { internal; } - include /home/dokku/gateway/nginx.conf.d/*.conf; - + include /home/dokku/gateway/nginx.conf.d/*.conf; } {{ end }} - +# Upstream setup {{ range $upstream_port := $.PROXY_UPSTREAM_PORTS | split " " }} upstream {{ $.APP }}-{{ $upstream_port }} { {{ range $listeners := $.DOKKU_APP_WEB_LISTENERS | split " " }} @@ -102,4 +143,4 @@ upstream {{ $.APP }}-{{ $upstream_port }} { server {{ $listener_ip }}:{{ $upstream_port }}; {{ end }} } -{{ end }} +{{ end }} \ No newline at end of file From 5c68cd3f6e9a410415accafb2bbbab5593f9292a Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:05:41 -0300 Subject: [PATCH 02/11] debug: errors with new lines --- nginx.conf.sigil | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index 7168104..3c388c9 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -1,16 +1,17 @@ +# sigil ver 2.1 dufok 2022-10-11 # Proxy settings -{{ $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_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_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_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;" }} # CORS headers based on request methods From 6f76a16f10dbf7d4a6d397d36e80a4e5f5aaf995 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:09:19 -0300 Subject: [PATCH 03/11] debug: errors with new lines --- nginx.conf.sigil | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index 3c388c9..91a3000 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -15,7 +15,7 @@ gzip_vary on; gzip_comp_level 6;" }} # CORS headers based on request methods -{{ $cors_headers_options := " +{{ $cors_headers_options := ' if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; @@ -25,7 +25,7 @@ if ($request_method = 'OPTIONS') { add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; -}" }} +}' }} {{ $cors_headers_post := " if ($request_method = 'POST') { From c8d47c4b106b23ba883a66c48eb2647df7ca013b Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:09:53 -0300 Subject: [PATCH 04/11] debug: errors with new lines --- nginx.conf.sigil | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index 91a3000..1481a7e 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -1,18 +1,18 @@ # sigil ver 2.1 dufok 2022-10-11 # Proxy settings -{{ $proxy_settings := "proxy_http_version 1.1; +{{ $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;" }} +proxy_set_header X-Request-Start $msec;' }} # GZIP settings -{{ $gzip_settings := "gzip on; +{{ $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;" }} +gzip_comp_level 6;' }} # CORS headers based on request methods {{ $cors_headers_options := ' From 980e3ae62ace53c1965c624bcca71243712f0cb5 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:14:43 -0300 Subject: [PATCH 05/11] debug: errors with new lines --- nginx.conf.sigil | 49 +++++++----------------------------------------- 1 file changed, 7 insertions(+), 42 deletions(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index 1481a7e..a83a09c 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -1,49 +1,12 @@ # sigil ver 2.1 dufok 2022-10-11 # Proxy settings -{{ $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;' }} - +{{ $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_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;' }} - +{{ $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;' }} # CORS headers based on request methods -{{ $cors_headers_options := ' -if ($request_method = 'OPTIONS') { - add_header 'Access-Control-Allow-Origin' '$allow_origin' always; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; - add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; - add_header 'Access-Control-Allow-Credentials' 'true'; - add_header 'Access-Control-Max-Age' 1728000; - add_header 'Content-Type' 'text/plain; charset=utf-8'; - add_header 'Content-Length' 0; - return 204; -}' }} - -{{ $cors_headers_post := " -if ($request_method = 'POST') { - add_header 'Access-Control-Allow-Origin' '$allow_origin' always; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; - add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; - add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; - add_header 'Access-Control-Allow-Credentials' 'true' always; -}" }} - -{{ $cors_headers_get := " -if ($request_method = 'GET') { - add_header 'Access-Control-Allow-Origin' '$allow_origin' always; - add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; - add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; - add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; - add_header 'Access-Control-Allow-Credentials' 'true' always; -}" }} +{{ $cors_headers_options := 'if ($request_method = "OPTIONS") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS"; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization"; add_header "Access-Control-Allow-Credentials" "true"; add_header "Access-Control-Max-Age" 1728000; add_header "Content-Type" "text/plain; charset=utf-8"; add_header "Content-Length" 0; return 204; }' }} +{{ $cors_headers_post := 'if ($request_method = "POST") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS" always; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always; add_header "Access-Control-Expose-Headers" "Content-Length,Content-Range" always; add_header "Access-Control-Allow-Credentials" "true" always; }' }} +{{ $cors_headers_get := 'if ($request_method = "GET") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS" always; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always; add_header "Access-Control-Expose-Headers" "Content-Length,Content-Range" always; add_header "Access-Control-Allow-Credentials" "true" always; }' }} # Mapping for allowed origins map $http_origin $allow_origin { @@ -66,7 +29,9 @@ server { server_name {{ $.NOSSL_SERVER_NAME }}; access_log /var/log/nginx/{{ $.APP }}-access.log; error_log /var/log/nginx/{{ $.APP }}-error.log; + {{ else if eq $scheme "https" }} + listen [::]:{{ $listen_port }} ssl http2; listen {{ $listen_port }} ssl http2; server_name {{ $.NOSSL_SERVER_NAME }}; From 048e110ce603a1ad94657b768aa2ff1ac85eb98a Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:16:05 -0300 Subject: [PATCH 06/11] debug: errors with new lines --- nginx.conf.sigil | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index a83a09c..68ef8da 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -1,12 +1,12 @@ # sigil ver 2.1 dufok 2022-10-11 # Proxy settings -{{ $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;' }} +{{ $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_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;' }} +{{ $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;" }} # CORS headers based on request methods -{{ $cors_headers_options := 'if ($request_method = "OPTIONS") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS"; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization"; add_header "Access-Control-Allow-Credentials" "true"; add_header "Access-Control-Max-Age" 1728000; add_header "Content-Type" "text/plain; charset=utf-8"; add_header "Content-Length" 0; return 204; }' }} -{{ $cors_headers_post := 'if ($request_method = "POST") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS" always; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always; add_header "Access-Control-Expose-Headers" "Content-Length,Content-Range" always; add_header "Access-Control-Allow-Credentials" "true" always; }' }} -{{ $cors_headers_get := 'if ($request_method = "GET") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS" always; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always; add_header "Access-Control-Expose-Headers" "Content-Length,Content-Range" always; add_header "Access-Control-Allow-Credentials" "true" always; }' }} +{{ $cors_headers_options := "if ($request_method = "OPTIONS") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS"; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization"; add_header "Access-Control-Allow-Credentials" "true"; add_header "Access-Control-Max-Age" 1728000; add_header "Content-Type" "text/plain; charset=utf-8"; add_header "Content-Length" 0; return 204; }" }} +{{ $cors_headers_post := "if ($request_method = "POST") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS" always; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always; add_header "Access-Control-Expose-Headers" "Content-Length,Content-Range" always; add_header "Access-Control-Allow-Credentials" "true" always; }" }} +{{ $cors_headers_get := "if ($request_method = "GET") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS" always; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always; add_header "Access-Control-Expose-Headers" "Content-Length,Content-Range" always; add_header "Access-Control-Allow-Credentials" "true" always; }" }} # Mapping for allowed origins map $http_origin $allow_origin { From 494c3f74389f241c0c737315cfb3bdbcba250576 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:17:27 -0300 Subject: [PATCH 07/11] debug: errors with new lines --- nginx.conf.sigil | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index 68ef8da..712cf35 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -4,9 +4,9 @@ # GZIP settings {{ $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;" }} # CORS headers based on request methods -{{ $cors_headers_options := "if ($request_method = "OPTIONS") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS"; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization"; add_header "Access-Control-Allow-Credentials" "true"; add_header "Access-Control-Max-Age" 1728000; add_header "Content-Type" "text/plain; charset=utf-8"; add_header "Content-Length" 0; return 204; }" }} -{{ $cors_headers_post := "if ($request_method = "POST") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS" always; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always; add_header "Access-Control-Expose-Headers" "Content-Length,Content-Range" always; add_header "Access-Control-Allow-Credentials" "true" always; }" }} -{{ $cors_headers_get := "if ($request_method = "GET") { add_header "Access-Control-Allow-Origin" "$allow_origin" always; add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS" always; add_header "Access-Control-Allow-Headers" "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always; add_header "Access-Control-Expose-Headers" "Content-Length,Content-Range" always; add_header "Access-Control-Allow-Credentials" "true" always; }" }} +{{ $cors_headers_options := "if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; }" }} +{{ $cors_headers_post := "if ($request_method = 'POST') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; add_header 'Access-Control-Allow-Credentials' 'true' always; }" }} +{{ $cors_headers_get := "if ($request_method = 'GET') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; add_header 'Access-Control-Allow-Credentials' 'true' always; }" }} # Mapping for allowed origins map $http_origin $allow_origin { From 973cf87309f47e17ef9ed08b55a70e69751978c3 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:22:31 -0300 Subject: [PATCH 08/11] debug: errors with new lines --- nginx.conf.sigil | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index 712cf35..b250106 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -1,8 +1,16 @@ # sigil ver 2.1 dufok 2022-10-11 # Proxy settings -{{ $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;" }} +{{ $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_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;" }} +{{ $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;" }} # CORS headers based on request methods {{ $cors_headers_options := "if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; }" }} {{ $cors_headers_post := "if ($request_method = 'POST') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; add_header 'Access-Control-Allow-Credentials' 'true' always; }" }} From f679c1c987442dad4120d191ad7a7c7d2934c69c Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:23:51 -0300 Subject: [PATCH 09/11] debug: errors with new lines --- nginx.conf.sigil | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index b250106..712cf35 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -1,16 +1,8 @@ # sigil ver 2.1 dufok 2022-10-11 # Proxy settings -{{ $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;" }} +{{ $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_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;" }} +{{ $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;" }} # CORS headers based on request methods {{ $cors_headers_options := "if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Max-Age' 1728000; add_header 'Content-Type' 'text/plain; charset=utf-8'; add_header 'Content-Length' 0; return 204; }" }} {{ $cors_headers_post := "if ($request_method = 'POST') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range' always; add_header 'Access-Control-Allow-Credentials' 'true' always; }" }} From 215ecb20f835259e1f02ea120078cd8a5ae5e587 Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:30:30 -0300 Subject: [PATCH 10/11] feat: port 80 for presence node --- nginx.conf.sigil | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index 712cf35..a797097 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -56,7 +56,7 @@ server { # Custom location block for /connect location /connect { - proxy_pass http://presence-8080; + proxy_pass http://presence-80; {{ $proxy_settings }} {{ $cors_headers_options }} {{ $cors_headers_post }} From 3d3d04078f93069a755a87ae8f64d13af8f1c47f Mon Sep 17 00:00:00 2001 From: Stepan Vladovskiy Date: Wed, 11 Oct 2023 09:33:40 -0300 Subject: [PATCH 11/11] feat: port 8080 for presence node --- nginx.conf.sigil | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx.conf.sigil b/nginx.conf.sigil index a797097..712cf35 100644 --- a/nginx.conf.sigil +++ b/nginx.conf.sigil @@ -56,7 +56,7 @@ server { # Custom location block for /connect location /connect { - proxy_pass http://presence-80; + proxy_pass http://presence-8080; {{ $proxy_settings }} {{ $cors_headers_options }} {{ $cors_headers_post }}