Skip to content

Instantly share code, notes, and snippets.

@dshoreman
Created June 28, 2017 16:34
Show Gist options
  • Save dshoreman/f633063f4f0739dafe5289b8e8b68de4 to your computer and use it in GitHub Desktop.
Save dshoreman/f633063f4f0739dafe5289b8e8b68de4 to your computer and use it in GitHub Desktop.
Example NginX config to block PHP execution in OctoberCMS
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
root /var/www/example.com;
index index.php index.html index.htm;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?/$1 break;
break;
}
#rewrite themes/.*/(layouts|pages|partials)/.*.htm /index.php break;
#rewrite uploads/protects/.* /index.php break;
#rewrite app/.* /index.php break;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
location ~ ^/(config|bootstrap|vendor|storage) {
deny all;
}
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
@jbess
Copy link

jbess commented Dec 25, 2017

Great work ! thanks !

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