diff --git a/deploy/nginx/https_redirect.conf b/deploy/nginx/https_redirect.conf new file mode 100644 index 00000000..71eb6c0d --- /dev/null +++ b/deploy/nginx/https_redirect.conf @@ -0,0 +1,3 @@ +location / { + return 301 https://$host$request_uri; +} \ No newline at end of file diff --git a/deploy/nginx/common.conf b/deploy/nginx/locations.conf similarity index 100% rename from deploy/nginx/common.conf rename to deploy/nginx/locations.conf diff --git a/deploy/nginx/nginx.conf b/deploy/nginx/nginx.conf index 01f7ae7e..cdf8fe12 100644 --- a/deploy/nginx/nginx.conf +++ b/deploy/nginx/nginx.conf @@ -36,7 +36,7 @@ http { listen 8000 default_server; server_name _; - include common.conf; + include http_locations.conf; } server { @@ -49,7 +49,7 @@ http { ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; - include common.conf; + include https_locations.conf; } } diff --git a/deploy/run.sh b/deploy/run.sh old mode 100644 new mode 100755 index 12f2db27..271e2fc2 --- a/deploy/run.sh +++ b/deploy/run.sh @@ -23,6 +23,14 @@ if [ ! -f "$SSL/server.key" ]; then -subj "/C=CN/ST=Beijing/L=Beijing/O=Beijing OnlineJudge Technology Co., Ltd./OU=Service Infrastructure Department/CN=`hostname`" -nodes fi +cd $APP/deploy/nginx +ln -sf locations.conf https_locations.conf +if [ -z "$FORCE_HTTPS" ]; then + ln -sf locations.conf http_locations.conf +else + ln -sf https_redirect.conf http_locations.conf +fi + cd $APP n=0