Moodle Nginx Config

From Tech Wiki
Revision as of 17:28, 30 April 2016 by Adam.birds (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here is the Nginx Config for Moodle:

  upstream examplecombackend {
    server unix:/var/run/php-fcgi-examplecom.sock;
  }

  server {
    listen 80;
    listen 443 ssl;
    server_name example.com;
    root /var/www/vhosts/example.com/htdocs;

    ssl_certificate      /etc/nginx/ssl/example.com.crt;
    ssl_certificate_key  /etc/nginx/ssl/example.com.key;
    ssl_protocols        TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers          RC4-SHA:!HIGH:!ADH;

    location / {
      index index.html index.php;
      try_files $uri $uri/ @handler;
      expires 30d;
    }

    location /app/                { deny all; }
    location /includes/           { deny all; }
    location /media/downloadable/ { deny all; }
    location /pkginfo/            { deny all; }
    location /report/config.xml   { deny all; }
    location /var/                { deny all; }

    location  /. {
      return 404;
    }

    location @handler {
      rewrite / /index.php;
    }

    location /dataroot/ {
      internal;
      alias /var/www/vhosts/example.com/moodledata/;
    }

    include "ssl_offloading.inc";

    location ~ [^/]\.php(/|$) {
      fastcgi_split_path_info  ^(.+\.php)(/.+)$;
      fastcgi_index            index.php;
      fastcgi_pass             examplecombackend;
      include                  fastcgi_params;
      fastcgi_param   PATH_INFO       $fastcgi_path_info;
      fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

  }