Skip to content

Instantly share code, notes, and snippets.

@jeffersonmartin
Created April 22, 2017 17:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jeffersonmartin/53802978e0728847854f741c3a17d6d8 to your computer and use it in GitHub Desktop.
Save jeffersonmartin/53802978e0728847854f741c3a17d6d8 to your computer and use it in GitHub Desktop.
Nginx Config for Moodle (with proper rewrite/paths)
server {
listen 80;
server_name learn.mydomain.com;
return 301 https://learn.mydomain.com$request_uri;
}
server {
listen 443 ssl;
server_name learn.mydomain.com;
root "/srv/www/learn.mydomain.com";
error_log /var/log/nginx/learn.mydomain.com-error.log;
access_log /var/log/nginx/learn.mydomain.com-access.log;
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/mydomain.com.chained.crt;
ssl_certificate_key /etc/nginx/ssl/mydomain.com.key;
}
@TrueBurn
Copy link

the URI rewrite actually breaks LTI mod as the fastcgi_split_path_info is no longer able to correctly extract the PATH_INFO variable

@alexmartins
Copy link

Thanks.

@psychogenic
Copy link

Finally! This works, many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment