Article

  • 10 years

    8 years

    YetiShare / Core

    30029

How to enable X-Accel-Redirect for Nginx

It is possible to let Nginx handle static file serving via X-Accel-Redirect. This dramatically increases performance for 'local' and 'direct' file storage, shifting the download process away from PHP and onto Nginx.

Documentation can be found in the Nginx Wiki section Mod X-Sendfile and section X-Accell. The header used by Nginx is X-Accel-Redirect. 

Installation

X-Accel-Redirect is supported by default in Nginx and no additional operation should be needed to install it.

Nginx Configuration

Configuration of X-Accel-Redirect for Nginx is below. In /etc/nginx/conf.d/default.conf add:

location ~ \.php$ {
    fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
}

location /files {
    root /root/path/to/yetishare;
    internal;
} 
  • Note: If any of the above 'location' sections already exist, just add the addition entries into them. Replace '/root/path/to/yetishare' with the full server path to your root YetiShare install.

Enable on YetiShare

Login to your admin area, go to 'file servers' navigation, click 'edit' on the relevant file server. Scroll to the 'Improved Downloads' option and select 'X-Accel-Redirect'.