File moodle3_10-nginx.conf of Package moodle3_10

server { 
    server_name moodle.example.com;

    log_not_found off;
    ## set_real_ip_from  192.168.0.1;
    ## set_real_ip_from  192.168.0.2;
    ## real_ip_header    X-Forwarded-For;

    error_log   /var/log/nginx/moodle_error.log;
    access_log  /var/log/nginx/moodle_access.log;

    gzip_vary on;
    gzip_min_length 1000;
    gzip_comp_level 5;
    gzip_types text/plain text/xml text/x-js application/json text/css application/x-javascript application/javascript;

    ## Setting Moodle and Nginx to use XSendfile functionality is a big win as
    ## it frees PHP from delivering files allowing Nginx to do what it does
    ## best, i.e. deliver files.
    ##
    ## Enable xsendfile for Nginx in Moodles config.php, this is documented in
    ## the config-dist.php, a minimal configuration look like this,
    ##
    ## $CFG->xsendfile = 'X-Accel-Redirect';
    ## $CFG->xsendfilealiases = array(
    ##     '/dataroot/' => $CFG->dataroot
    ## );
    ## 
    ## After that change, accompany this with a matching 'location' block in
    ## your nginx server configuration (just uncomment the following if you used
    ## the example above in your config.php):   
    #location /dataroot/ {
    #    internal;
    #    alias MOODLEDATADIR/; # ensure the path ends with /
    #}

    root MOODLEROOTDIR;
    index index.php;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ [^/]\.php(/|$) {
        fastcgi_keep_conn        on;
        fastcgi_index            index.php;
        fastcgi_pass             127.0.0.1:9000;
        include                  /etc/nginx/fastcgi_params;

        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        fastcgi_param   PATH_INFO       $fastcgi_path_info;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;

        fastcgi_read_timeout 1200;
    }

    # disable all access to files starting with .ht (apache)
    location ~ /\.ht {
        deny  all;
        return 403;
    }

    location /dataroot/ {
        internal;
        alias /srv/www/moodledata/;
    }

    # redirect server error pages to the static page /50x.html
    error_page   500 502 503 504  /50x.html;
}

openSUSE Build Service is sponsored by