From 5f5e2e36034c48aadb345308fa3d1b019a269306 Mon Sep 17 00:00:00 2001 From: gyurix Date: Thu, 16 Sep 2021 18:50:52 +0000 Subject: [PATCH] Bugfixes at nginx config create. --- scripts/nginx_config_create.sh | 41 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/scripts/nginx_config_create.sh b/scripts/nginx_config_create.sh index e6ccfd4..8d053da 100755 --- a/scripts/nginx_config_create.sh +++ b/scripts/nginx_config_create.sh @@ -50,33 +50,32 @@ echo echo "return 301 $REDIRECT_HTTPS;" else - if [[ $ERROR_PAGE != "" && $HTTP_PORT != "" ]]; then - echo "error_page 404 /$ERROR_PAGE; + echo "location / {" + + if [[ $HTTP_PORT != "" ]]; then + echo "proxy_pass http://$LOCAL_IP:$HTTP_PORT;" + else + echo "proxy_pass http://$LOCAL_IP:80;" + fi + + echo "proxy_redirect off; + proxy_buffering off; + proxy_set_header X-Forwarded-For "'$proxy_add_x_forwarded_for'"; + proxy_set_header Upgrade "'$http_upgrade'"; + proxy_set_header Connection "'$http_connection'"; + proxy_cookie_path / /; + access_log off; + }" + if [[ $ERROR_PAGE != "" && $HTTP_PORT != "" ]]; then + echo "error_page 404 /$ERROR_PAGE; location = /$ERROR_PAGE { root html; allow all; index 404.html; rewrite ^ "'$scheme'" http://$ERROR_PAGE"'$request_uri'" permanent; }" - fi - fi - echo "location / {" - - if [[ $HTTP_PORT != "" ]]; then - echo "proxy_pass http://$LOCAL_IP:$HTTP_PORT;" - else - echo "proxy_pass http://$LOCAL_IP:80;" - fi - - echo "proxy_redirect off; - proxy_buffering off; - proxy_set_header X-Forwarded-For "'$proxy_add_x_forwarded_for'"; - proxy_set_header Upgrade "'$http_upgrade'"; - proxy_set_header Connection "'$http_connection'"; - proxy_cookie_path / /; - access_log off; - } -}" + fi +echo "}" fi if [[ $HTTPS_PORT != "" ]]; then