diff --git a/deploy/entrypoint.sh b/deploy/entrypoint.sh index 37bf799e..055123ca 100755 --- a/deploy/entrypoint.sh +++ b/deploy/entrypoint.sh @@ -31,6 +31,12 @@ else ln -sf https_redirect.conf http_locations.conf fi +if [ ! -z "$LOWER_IP_HEADER" ]; then + sed -i "s/__IP_HEADER__/\$http_$LOWER_IP_HEADER/g" api_proxy.conf; +else + sed -i "s/__IP_HEADER__/\$remote_addr/g" api_proxy.conf; +fi + cd $APP/dist if [ ! -z "$STATIC_CDN_HOST" ]; then find . -name index.html -exec sed -i "s/link href=\/static/link href=\/\/$STATIC_CDN_HOST\/static/g" {} \; diff --git a/deploy/nginx/api_proxy.conf b/deploy/nginx/api_proxy.conf new file mode 100644 index 00000000..631103d9 --- /dev/null +++ b/deploy/nginx/api_proxy.conf @@ -0,0 +1,5 @@ +proxy_pass http://backend; +proxy_set_header X-Real-IP __IP_HEADER__; +proxy_set_header Host $http_host;client_max_body_size 200M; +proxy_http_version 1.1; +proxy_set_header Connection ''; \ No newline at end of file diff --git a/deploy/nginx/https_redirect.conf b/deploy/nginx/https_redirect.conf index 71eb6c0d..88d81036 100644 --- a/deploy/nginx/https_redirect.conf +++ b/deploy/nginx/https_redirect.conf @@ -1,3 +1,7 @@ +location /api/judge_server_heartbeat { + include api_proxy.conf; +} + location / { return 301 https://$host$request_uri; } \ No newline at end of file diff --git a/deploy/nginx/locations.conf b/deploy/nginx/locations.conf index 1732c7e7..a096ffa6 100644 --- a/deploy/nginx/locations.conf +++ b/deploy/nginx/locations.conf @@ -3,10 +3,7 @@ location /public { } location /api { - proxy_pass http://backend; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header Host $http_host; - client_max_body_size 200M; + include api_proxy.conf; } location /data/ {