diff --git a/conf/nginx.conf b/conf/nginx.conf index d7b75ab..336e2ae 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,27 +1,28 @@ -location #LOCATION# { - alias #DESTDIR#/html; - if ($scheme = http) { - rewrite ^ https://$server_name$request_uri? permanent; - } - - index index.php; - - location ~ ^(.+\.php)(.*)$ { - fastcgi_split_path_info ^(.+\.php)(.*)$; - fastcgi_pass unix:/var/run/php5-fpm.sock; - include fastcgi_params; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param SCRIPT_FILENAME $request_filename; - } +location = {PATH}/.well-known/carddav { + return 301 https://$server_name{PATH}/card.php; +} +location = {PATH}/.well-known/caldav { + return 301 https://$server_name{PATH}/cal.php; } -location ~ ^#PATH#/(\.|Core|Specific) { +location {LOCATION} { + alias {DESTDIR}/html/; + + if ($scheme = http) { + return 301 https://$server_name$request_uri; + } + + index index.php; + + location ~ ^(.+\.php)(.*)$ { + fastcgi_split_path_info ^(.+\.php)(.*)$; + fastcgi_pass unix:/var/run/php5-fpm.sock; + include fastcgi_params; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + } + + location ~ ^{PATH}/(\.|Core|Specific) { deny all; -} - -location /.well-known/carddav { - rewrite ^(.*)$ #PATH#/card.php redirect; -} -location /.well-known/caldav { - rewrite ^(.*)$ #PATH#/cal.php redirect; + } } diff --git a/scripts/install b/scripts/install index 30635e2..fad3fcf 100644 --- a/scripts/install +++ b/scripts/install @@ -64,9 +64,9 @@ sudo chown -R www-data: "$DESTDIR" # Copy and set nginx configuration nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" -sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf -sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf -sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf +sed -i "s@{PATH}@${path}@g" ../conf/nginx.conf +sed -i "s@{LOCATION}@${path:-/}@g" ../conf/nginx.conf +sed -i "s@{DESTDIR}@${DESTDIR}@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf "$nginx_conf" # Save app settings diff --git a/scripts/upgrade b/scripts/upgrade index e7b3dff..06e5bd1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -45,9 +45,9 @@ sudo chown -R www-data: "$DESTDIR" # Copy and set nginx configuration nginx_conf="/etc/nginx/conf.d/${domain}.d/${app}.conf" -sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf -sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf -sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf +sed -i "s@{PATH}@${path}@g" ../conf/nginx.conf +sed -i "s@{LOCATION}@${path:-/}@g" ../conf/nginx.conf +sed -i "s@{DESTDIR}@${DESTDIR}@g" ../conf/nginx.conf sudo cp ../conf/nginx.conf "$nginx_conf" # Set SSOwat rules