Skip to content

Instantly share code, notes, and snippets.

@kwbtdisk
Created February 9, 2017 12:23
Show Gist options
  • Save kwbtdisk/f0eac0927eabfa9865c69d2fd87c3cd1 to your computer and use it in GitHub Desktop.
Save kwbtdisk/f0eac0927eabfa9865c69d2fd87c3cd1 to your computer and use it in GitHub Desktop.
Mautic on kusanagi nginx.conf
#=======================================
# mautic on kusanagi
#---------------------------------------
server {
listen 80;
server_name mautic.xxx.site ;
access_log /home/kusanagi/provision_name/log/nginx/access.log main;
error_log /home/kusanagi/provision_name/log/nginx/error.log warn;
# rewrite ^(.*)$ https://mautic.xxx.site$request_uri permanent; # SSL ONLY
charset UTF-8;
client_max_body_size 16M;
root /home/kusanagi/provision_name/DocumentRoot;
index index.php index.html index.htm;
# location / {
# try_files $uri $uri/ /index.php?$args;
# }
# location = /favicon.ico {
# log_not_found off;
# access_log off;
# }
location ~* /\.well-known {
allow all;
}
# location ~* /\. {
# deny all;
# }
# location ~* \.(jpg|jpeg|gif|png|css|js|swf|ico|pdf|svg|eot|ttf|woff)$ {
# access_log off;
# }
# Ref: https://gist.github.com/that0n3guy/905c812c0f65e7ffb5ec
#######################################
## Start Mautic Specific config #####
#######################################
# redirect some entire folders
rewrite ^/(vendor|translations|build)/.* /index.php break;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to index.html
# one option: try_files $uri $uri/ /index.php$is_args$args;
try_files $uri /index.php$is_args$args;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Deny everything else in /app folder except Assets folder in bundles
location ~ /app/bundles/.*/Assets/ {
allow all;
access_log off;
}
location ~ /app/ { deny all; }
# Deny everything else in /addons or /plugins folder except Assets folder in bundles
location ~ /(addons|plugins)/.*/Assets/ {
allow all;
access_log off;
}
location ~ /(addons|plugins)/ { deny all; }
# Deny all php files in themes folder
location ~* ^/themes/(.*)\.php {
deny all;
}
# Don't log favicon
location = /favicon.ico {
log_not_found off;
access_log off;
}
# Don't log robots
location = /robots.txt {
access_log off;
log_not_found off;
}
# Deny yml, twig, markdown, init file access
location ~* /(.*)\.(?:markdown|md|twig|yaml|yml|ht|htaccess|ini)$ {
deny all;
access_log off;
log_not_found off;
}
# Deny all attempts to access hidden files/folders such as .htaccess, .htpasswd, .DS_Store (Mac), etc...
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# Deny all grunt, composer files
location ~* (Gruntfile|package|composer)\.(js|json)$ {
deny all;
access_log off;
log_not_found off;
}
#######################################
## End Mautic Specific config #####
#######################################
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_buffers 256 128k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
fastcgi_read_timeout 120s;
set $do_not_cache 1; ## page cache
set $device "pc";
if ($request_method = POST) {
set $do_not_cache 1;
}
if ($query_string != "") {
set $do_not_cache 1;
}
if ($http_user_agent ~* " Android |\(iPad|Android; Tablet; .+Firefox") {
set $device "tablet";
}
if ($http_user_agent ~* " Android .+ Mobile |\(iPhone|\(iPod|IEMobile|Android; Mobile; .+Firefox|Windows Phone") {
set $device "smart";
}
fastcgi_cache wpcache;
fastcgi_cache_key "$device:$request_method:$scheme://$host$request_uri";
fastcgi_cache_valid 200 10m;
fastcgi_no_cache $do_not_cache;
fastcgi_cache_bypass $do_not_cache;
add_header X-F-Cache $upstream_cache_status;
add_header X-Signature KUSANAGI;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment