From 2b4291d2362586da99ff36bb1799afe49bd3b7ea Mon Sep 17 00:00:00 2001 From: anmol26s <5068843+anmol26s@users.noreply.github.com> Date: Tue, 3 Jul 2018 04:28:26 +0530 Subject: [PATCH] Updated nginx --- conf/nginx.conf | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 55d8d7e..e2b495d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -7,19 +7,37 @@ location __PATH__/ { rewrite ^ https://$server_name$request_uri? permanent; } - #enable subsonic api - if ( !-d $request_filename ) { - rewrite ^__PATH__/rest/(.*)\.view$ __PATH__/rest/index.php?action=$1 last; - rewrite ^__PATH__/rest/fake/(.+)$ __PATH__/play/$1 last; - } - - rewrite ^__PATH__/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/player/(.*)/name/(.*)$ __PATH__/play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&player=$7&name=$8 last; - rewrite ^__PATH__/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/bitrate/([0-9]+)/player/(.*)/name/(.*)$ __PATH__/play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&bitrate=$7player=$8&name=$9 last; - rewrite ^__PATH__/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/transcode_to/(w+)/bitrate/([0-9]+)/player/(.*)/name/(.*)$ __PATH__/play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&transcode_to=$7&bitrate=$8&player=$9&name=$10 last; - + # Rewrite rule for Subsonic backend + if ( !-d $request_filename ) { + rewrite ^/rest/(.*).view$ /rest/index.php?action=$1 last; + rewrite ^/rest/fake/(.+)$ /play/$1 last; + } + + # Rewrite rule for Channels + if (!-d $request_filename){ + rewrite ^/channel/([0-9]+)/(.*)$ /channel/index.php?channel=$1&target=$2 last; + } + + # Beautiful URL Rewriting + rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&name=$5 last; + rewrite ^/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&name=$7 last; + rewrite ^/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/player/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&player=$7&name=$8 last; + rewrite ^/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/transcode_to/(w+)/bitrate/([0-9]+)/player/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&transcode_to=$7&bitrate=$8&player=$9&name=$10 last; + + # the following line was needed for me to get downloads of single songs to work + rewrite ^/play/ssid/(.*)/type/(.*)/oid/([0-9]+)/uid/([0-9]+)/action/(.*)/name/(.*)$ /play/index.php?ssid=$1&type=$2&oid=$3&uid=$4action=$5&name=$6 last; + location /play { + if (!-e $request_filename) { + rewrite ^/play/art/([^/]+)/([^/]+)/([0-9]+)/thumb([0-9]*)\.([a-z]+)$ /image.php?object_type=$2&object_id=$3&auth=$1 last; + } + + rewrite ^/([^/]+)/([^/]+)(/.*)?$ /play/$3?$1=$2; + rewrite ^/(/[^/]+|[^/]+/|/?)$ /play/index.php last; + break; + } index index.php; try_files $uri $uri/ index.php; - location ~ [^/]\.php(/|$) { + location ~ ^/.*.php { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; @@ -39,9 +57,6 @@ location __PATH__/ { return 403; } - rewrite ^__PATH__/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/name/(.*)$ __PATH__/play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&name=$5 last; - rewrite ^__PATH__/play/ssid/(\w+)/type/(\w+)/oid/([0-9]+)/uid/([0-9]+)/client/(.*)/noscrobble/([0-1])/name/(.*)$ __PATH__/play/index.php?ssid=$1&type=$2&oid=$3&uid=$4&client=$5&noscrobble=$6&name=$7 last; - location __PATH__/rest { limit_except GET POST { deny all;