Skip to content

Instantly share code, notes, and snippets.

@IamSwap
Last active February 28, 2017 18:45
Show Gist options
  • Save IamSwap/8af1affab92bd666dc09 to your computer and use it in GitHub Desktop.
Save IamSwap/8af1affab92bd666dc09 to your computer and use it in GitHub Desktop.
Nginx Configuration file for Grav CMS
server {
# Listen ports
listen 80;
listen [::]:80;
# Make site accessible from http://grav.dev/
server_name grav.dev www.grav.dev;
root /var/www/grav.dev;
index index.html index.htm index.php;
charset utf-8;
# Url Rewrite For Grav
location / {
index index.php;
if (!-e $request_filename){ rewrite ^(.*)$ /index.php last; }
}
location /user {
rewrite ^/user/accounts/(.*)$ /error redirect;
rewrite ^/user/config/(.*)$ /error redirect;
rewrite ^/user/(.*)\.(txt|md|html|php|yaml|json|twig|sh|bat)$ /error redirect;
}
location /cache {
rewrite ^/cache/(.*) /error redirect;
}
location /bin {
rewrite ^/bin/(.*)$ /error redirect;
}
location /system {
rewrite ^/system/(.*)$ /error redirect;
}
location /vendor {
rewrite ^/vendor/(.*)$ /error redirect;
}
# Remember to change 127.0.0.1:9000 to the Ip/port
# you configured php-cgi.exe to run from
access_log off;
error_log /var/log/nginx/grav-error.log error;
sendfile off;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment