debug: rewrite nginx file to use it without variables logic
All checks were successful
Deploy on push / deploy (push) Successful in 57s
All checks were successful
Deploy on push / deploy (push) Successful in 57s
This commit is contained in:
parent
cd8f5977af
commit
95f49a7ca5
|
@ -5,14 +5,10 @@ log_format custom '$remote_addr - $remote_user [$time_local] "$request" '
|
||||||
{{ $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 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_options := "if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '$allow_origin' always; add_header 'Access-Control-Allow-Methods' 'POST, GET, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always; add_header 'Access-Control-Allow-Credentials' 'true' always; 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' 'POST, GET, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' 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' 'POST, GET, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always; add_header 'Access-Control-Allow-Credentials' 'true' always; }" }}
|
|
||||||
|
|
||||||
map $http_origin $allow_origin {
|
map $http_origin $allow_origin {
|
||||||
~^https?:\/\/(.*\.)?localhost(:\d+)?$ $http_origin;
|
~^https?:\/\/(.*\.)?localhost(:\d+)?$ $http_origin;
|
||||||
~^https?:\/\/(.*\.)?discours\.io$ $http_origin;
|
~^https?:\/\/(.*\.)?discours\.io$ $http_origin;
|
||||||
~^https?:\/\/(.*\.)?dscrs\.site$ "https://testing.discours.io";
|
~^https?:\/\/(.*\.)?dscrs\.site$ $http_origin;
|
||||||
~^https?:\/\/discoursio-webapp(-.*)?\.vercel\.app$ $http_origin;
|
~^https?:\/\/discoursio-webapp(-.*)?\.vercel\.app$ $http_origin;
|
||||||
default "";
|
default "";
|
||||||
}
|
}
|
||||||
|
@ -60,11 +56,34 @@ server {
|
||||||
proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
|
proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
|
||||||
{{ $proxy_settings }}
|
{{ $proxy_settings }}
|
||||||
{{ $gzip_settings }}
|
{{ $gzip_settings }}
|
||||||
{{ $cors_headers_options }}
|
|
||||||
{{ $cors_headers_post }}
|
|
||||||
{{ $cors_headers_get }}
|
|
||||||
|
|
||||||
add_header Debug-Allow-Origin $allow_origin;
|
# Handle CORS for OPTIONS method
|
||||||
|
if ($request_method = 'OPTIONS') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' $allow_origin always;
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'POST, GET, OPTIONS';
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
|
||||||
|
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||||||
|
add_header 'Access-Control-Max-Age' 1728000;
|
||||||
|
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
||||||
|
add_header 'Content-Length' 0;
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Handle CORS for POST method
|
||||||
|
if ($request_method = 'POST') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' $allow_origin always;
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'POST, GET, OPTIONS' always;
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
|
||||||
|
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Handle CORS for GET method
|
||||||
|
if ($request_method = 'GET') {
|
||||||
|
add_header 'Access-Control-Allow-Origin' $allow_origin always;
|
||||||
|
add_header 'Access-Control-Allow-Methods' 'POST, GET, OPTIONS' always;
|
||||||
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization' always;
|
||||||
|
add_header 'Access-Control-Allow-Credentials' 'true' always;
|
||||||
|
}
|
||||||
|
|
||||||
proxy_cache my_cache;
|
proxy_cache my_cache;
|
||||||
proxy_cache_revalidate on;
|
proxy_cache_revalidate on;
|
||||||
|
@ -77,16 +96,6 @@ server {
|
||||||
limit_req zone=req_zone burst=10 nodelay;
|
limit_req zone=req_zone burst=10 nodelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Custom location block for /upload
|
|
||||||
# location /upload {
|
|
||||||
# proxy_pass http://uploader-8080/;
|
|
||||||
# {{ $proxy_settings }}
|
|
||||||
# {{ $gzip_settings }}
|
|
||||||
# {{ $cors_headers_options }}
|
|
||||||
# {{ $cors_headers_post }}
|
|
||||||
# {{ $cors_headers_get }}
|
|
||||||
# }
|
|
||||||
|
|
||||||
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
|
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
|
||||||
proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
|
proxy_pass http://{{ $.APP }}-{{ $upstream_port }};
|
||||||
expires 30d;
|
expires 30d;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user