NGINX Proxy Production Directives [media.vidmax.com]

9 March 2016 by admin

These are specific directives for media.vidmax.com. For their preview / thumbnail images, vidmax.com uses a file-exists check to either serve a cached image from disk, or send the request to a php-controller which creates the image and then serves it. The standard Yavli proxy configuration clashes with this, but the below directives have been designed to be compatible with the preview / thumbnail images.

Partial media.vidmax.com configuration

Please note that the below directives include partial configuration directives from the supplied NGINX config. This is here to provide a contextual explanation for how and where the Yavli configuration directives should be implemented.

Directives

...snip...

server {
  listen 80;
  server_name media.vidmax.com ;
  root /home/media.vidmax.com/public_html;

  try_files $uri @redirect;

  location @redirect {
    # rewrite ^/(.*)$ http://vidmax.com/prev/$1 permanent;
    rewrite ^/(.*)$ /prev/$1 break;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $host;
    proxy_pass http://vidmax.com;
 
    proxy_intercept_errors on;
    error_page 404 = @yavli;
  }
 
  location @yavli {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $host;
    proxy_pass http://steg.yavli.com;
  }
 
  location ~ \.mp4 {
    mp4;
  }

  location ~ \.flv {
    flv;
  }

  # Check to see if thumbnail exists, if not, process
  location /prev/ {
    expires 8d;
    rewrite ^/prev(.*)$ /$1;
    try_files /media/thumbs$uri @redirect;
    break;
  }
}
...snip...