Created
June 28, 2017 16:34
-
-
Save dshoreman/f633063f4f0739dafe5289b8e8b68de4 to your computer and use it in GitHub Desktop.
Example NginX config to block PHP execution in OctoberCMS
This file contains hidden or 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 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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great work ! thanks !