Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Nginx Config for Moodle (with proper rewrite/paths)
server {
listen 80;
return 301$request_uri;
server {
listen 443 ssl;
root "/srv/www/";
error_log /var/log/nginx/;
access_log /var/log/nginx/;
rewrite ^/(.*\.php)(/)(.*)$ /$1?file=/$3 last;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php;
fastcgi_intercept_errors on;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
location ~ /\.ht {
deny all;
ssl_certificate /etc/nginx/ssl/;
ssl_certificate_key /etc/nginx/ssl/;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment