Last active
March 18, 2025 11:54
-
-
Save IamSwap/8af1affab92bd666dc09 to your computer and use it in GitHub Desktop.
Nginx Configuration file for Grav CMS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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