File moodle3_4-nginx.conf of Package moodle3_4

server { 
    server_name moodle.example.com;
    log_not_found off;
    error_log   /var/log/nginx/moodle_error.log;
    access_log  /var/log/nginx/moodle_access.log;

    location / {
        root MOODLEROOTDIR;
        index index.php index.html;
        # moodle rewrite rules
        rewrite ^/(.*.php)(/)(.*)$ /$1?file=/$3 last;
    }

	## 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 /
    #}

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info  ^(.+\.php)(/.+)$;
        fastcgi_index            index.php;
        # put either the path to your php-fpm socket or port below:
        # fastcgi_pass unix:/run/php7-fpm.sock;
        fastcgi_pass             127.0.0.1:9000;
        include                  ../fastcgi_params;
        fastcgi_param   PATH_INFO       $fastcgi_path_info;
        fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_buffer_size             128k;
        fastcgi_buffers                 256 4k;
        fastcgi_busy_buffers_size       256k;
        fastcgi_connect_timeout         600;
        fastcgi_send_timeout            600;
        fastcgi_read_timeout            600;
        fastcgi_temp_file_write_size    256k;
    }

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

openSUSE Build Service is sponsored by