Advertisement
rockdrilla

UniFi AP controller

Jun 17th, 2016
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.42 KB | None | 0 0
  1. server
  2. {
  3.         server_name _ "" " ";
  4.         listen  10.49.13.10:80  default_server bind deferred;
  5.  
  6.         root /usr/lib/unifi/;
  7.         try_files $uri @unifi_proxy;
  8.  
  9.         set $unifi_ep  [::1]:8443;
  10.         set $unifi_uri https://$unifi_ep;
  11.  
  12.         location @unifi_proxy
  13.         {
  14.                 proxy_pass      $unifi_uri;
  15.                 proxy_redirect  $unifi_uri  $scheme://$server_addr;
  16.  
  17.                 proxy_http_version  1.1;
  18.                 proxy_ssl_verify    off;
  19.  
  20.                 proxy_buffering          off;
  21.                 proxy_request_buffering  off;
  22.                 proxy_cache              off;
  23.  
  24.                 proxy_connect_timeout  5s;
  25.                 proxy_read_timeout    10s;
  26.                 proxy_send_timeout    10s;
  27.  
  28.                 proxy_pass_header Set-Cookie;
  29.  
  30.                 ##########################################################
  31.                 ### fix incoming HTTP Origin & Referer
  32.                 #
  33.                 set  $krd_in_origin   $http_origin;
  34.                 set  $krd_in_referer  $http_referer;
  35.  
  36.                 if ($http_origin  ~ '^http://10.49.13.10(.*)$')  { set  $krd_in_origin   $unifi_uri$1; }
  37.                 if ($http_referer ~ '^http://10.49.13.10(/.+)$') { set  $krd_in_referer  $unifi_uri$1; }
  38.  
  39.                 proxy_set_header  Origin   $krd_in_origin;
  40.                 proxy_set_header  Referer  $krd_in_referer;
  41.  
  42.                 ##########################################################
  43.                 ### fix outgoing HTTP Set-Cookie
  44.                 #
  45.  
  46.                 header_filter_by_lua '
  47.                        local cookies = ngx.header.set_cookie
  48.                        if not cookies then return end
  49.  
  50.                        if type(cookies) == "string" then cookies = {cookies} end
  51.                        local newcookies = {}
  52.  
  53.                        for i, cookie in ipairs(cookies) do
  54.                        local newcookie = string.gsub(cookie, "; [Ss]ecure", "")
  55.                                table.insert(newcookies, newcookie)
  56.                        end
  57.                        ngx.header.set_cookie = newcookies
  58.                ';
  59.         }
  60.  
  61.         location /manage/
  62.         {
  63.                 alias /usr/lib/unifi/webapps/ROOT/app-unifi/;
  64.                 try_files $uri @unifi_proxy;
  65.  
  66.                 include snippets/area.cdn;
  67.  
  68.                 location /manage/.version { default_type text/plain; }
  69.         }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement