Advertisement
Guest User

Untitled

a guest
May 18th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 3.93 KB | None | 0 0
  1. server {
  2.  
  3.     # listen to
  4.     listen  [::]:80; #ssl; ipv6 optional with ssl enabled
  5.     listen       80; #ssl; ipv4 optional with ssl enabled
  6.  
  7.     server_name zik.sxbn.org;
  8.     charset utf-8;
  9.  
  10.     # Logging, error_log mode [notice] is necessary for rewrite_log on,
  11.     # (very usefull if rewrite rules do not work as expected)
  12.  
  13.          error_log       /var/log/ampache/error.log; # notice;
  14.        # access_log      /var/log/ampache/access.log;
  15.        # rewrite_log     on;
  16.  
  17.     # only optional for ssl encryption enabled: Path to certificate/key
  18.  
  19.         # ssl_certificate         /etc/ssl/certs/cert.crt;
  20.         # ssl_certificate_key     /etc/ssl/private/key.key;
  21.  
  22.     root /var/www/ampache;
  23.     index index.php;
  24.  
  25.     # Somebody said this helps, in my setup it doesn't prevent temporary saving in files
  26.     proxy_max_temp_file_size 0;
  27.  
  28.     # Rewrite rule for Subsonic backend
  29.     if ( !-d $request_filename ) {
  30.         rewrite ^/rest/(.*).view$ /rest/index.php?action=$1 last;
  31.         rewrite ^/rest/fake/(.+)$ /play/$1 last;
  32.     }
  33.  
  34.     # Rewrite rule for Channels
  35.     if (!-d $request_filename){
  36.       rewrite ^/channel/([0-9]+)/(.*)$ /channel/index.php?channel=$1&target=$2 last;
  37.     }
  38.  
  39.     # Beautiful URL Rewriting
  40.         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;
  41.         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;
  42.         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;
  43.         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;
  44.  
  45.     # the following line was needed for me to get downloads of single songs to work
  46.         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;
  47.         location /play {
  48.                 if (!-e $request_filename) {
  49.                 rewrite ^/play/art/([^/]+)/([^/]+)/([0-9]+)/thumb([0-9]*)\.([a-z]+)$ /image.php?object_type=$2&object_id=$3&auth=$1 last;
  50.                 }
  51.  
  52.         rewrite ^/([^/]+)/([^/]+)(/.*)?$ /play/$3?$1=$2;
  53.         rewrite ^/(/[^/]+|[^/]+/|/?)$ /play/index.php last;
  54.         break;
  55.         }
  56.  
  57.    location /rest {
  58.       limit_except GET POST {
  59.          deny all;
  60.       }
  61.    }
  62.  
  63.    location ^~ /bin/ {
  64.       deny all;
  65.       return 403;
  66.    }
  67.  
  68.    location ^~ /config/ {
  69.       deny all;
  70.       return 403;
  71.    }
  72.  
  73.    location / {
  74.       limit_except GET POST HEAD{
  75.          deny all;
  76.       }
  77.    }
  78.  
  79.    location ~ ^/.*.php {
  80.         fastcgi_index index.php;
  81.  
  82.     # sets the timeout for requests in [s] , 60s are normally enough
  83.         fastcgi_read_timeout 600s;
  84.  
  85.         include fastcgi_params;
  86.         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  87.  
  88.     # Mitigate HTTPOXY https://httpoxy.org/
  89.         fastcgi_param HTTP_PROXY "";
  90.  
  91.     # has to be set to on if encryption (https) is used:
  92.         # fastcgi_param HTTPS on;
  93.  
  94.         fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  95.  
  96.     # chose as your php-fpm is configured to listen on
  97.         fastcgi_pass unix:/var/run/php5-fpm.sock;
  98.         # fastcgi_pass 127.0.0.1:8000/;
  99.    }
  100.  
  101.    # Rewrite rule for WebSocket
  102.    location /ws {
  103.         rewrite ^/ws/(.*) /$1 break;
  104.         proxy_http_version 1.1;
  105.         proxy_set_header Upgrade $http_upgrade;
  106.         proxy_set_header Connection "upgrade";
  107.         proxy_set_header Host $host;
  108.         proxy_pass http://127.0.0.1:8100/;
  109.    }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement