Skip to content

Instantly share code, notes, and snippets.

@1242035
Created November 12, 2019 13:28
Show Gist options
  • Save 1242035/2f473c34053ee1d69b4064c4552824c9 to your computer and use it in GitHub Desktop.
Save 1242035/2f473c34053ee1d69b4064c4552824c9 to your computer and use it in GitHub Desktop.
nginx x-cart.conf
server {
listen 80;
listen [::]:80;
root /home/cherry/Desktop/x-cart;
server_name x-cart.test;
index cart.php;
charset UTF-8;
location ^~ /classes {
deny all;
}
location ^~ /etc {
deny all;
}
location ^~ /files {
location ^~ /files/attachments {
try_files $uri =404;
}
location ^~ /files/vendor {
try_files $uri =404;
}
return 403;
}
location ^~ /images {
location ~* \.(jpg|jpeg|gif|png|bmp|ico|tiff|flv|swf|svg|pdf) {
try_files $uri =404;
}
return 403;
}
location ^~ /Includes {
deny all;
}
location ^~ /lib {
deny all;
}
location ^~ /skins {
location ~* \.(tpl|twig|php|pl|conf) {
deny all;
}
try_files $uri =404;
}
location ^~ /sql {
deny all;
}
location ^~ /var {
location ~* \.(gif|jpe?g|png|bmp|css|js) {
try_files $uri =404;
}
return 403;
}
location ^~ /vendor {
deny all;
}
location ^~ /var/export {
deny all;
}
location ^~ /var/import {
deny all;
}
location ^~ /service/ {
location ^~ /service/static/ {
try_files $uri =404;
}
return 403;
}
location / {
try_files $uri $uri/ @handler;
}
location @handler {
rewrite ^/sitemap.xml(\?.+)?$ /cart.php?target=sitemap;
rewrite ^/service.php(.*)?$ /service.php last;
rewrite ^/(.*)$ /cart.php?url=$1 last;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_connect_timeout 1200s;
fastcgi_send_timeout 1200s;
fastcgi_read_timeout 1200s;
}
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types
text/plain
text/css
text/js
text/xml
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/xml+rss
image/svg+xml;
gzip_vary on;
# Banned locations (only reached if the earlier PHP entry point regexes don't match)
location ~* (\.php$|\.htaccess$|\.git) {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment