From e3c77dd4b5bc716c97c658d6eede6b955799f469 Mon Sep 17 00:00:00 2001 From: Limezy Date: Sat, 26 Mar 2022 21:51:16 +0700 Subject: [PATCH] Update nginx conf To have server working, not only console ! --- .gitignore | 2 ++ conf/nginx.conf | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bea433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store diff --git a/conf/nginx.conf b/conf/nginx.conf index 7bcebc4..5f21422 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,7 +1,12 @@ -#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; -location __PATH__/ { +rewrite ^$ /; +location ~ ^(/api|/login|/styles|/static|/manifest.json|/$) { - proxy_pass http://127.0.0.1:__CONSOLE_PORT__/; +# Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + proxy_pass http://127.0.0.1:__CONSOLE_PORT__; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_cache_bypass $http_upgrade; @@ -14,4 +19,28 @@ location __PATH__/ { 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; + } + +location ~ / { + +# Force usage of https + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + + proxy_pass http://127.0.0.1:__PORT__; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_cache_bypass $http_upgrade; + proxy_ignore_client_abort on; + client_max_body_size 200M; + + # forward headers + proxy_buffering off; + proxy_set_header Host $http_host; + 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; + +} \ No newline at end of file