Last active
October 12, 2019 16:51
-
-
Save spiffin/5100d8d790c8c480b0133c9f8292a22d to your computer and use it in GitHub Desktop.
Nginx configuration for Koken 0.22.21 (2017)
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 { | |
# General | |
# Listen on both ipv4 and ipv6 | |
listen 80; | |
listen [::]:80; | |
server_name MYDOMAIN.COM; | |
root /data/www/MYDOMAIN>COM/public; | |
index index.php index.html; | |
charset utf-8; | |
access_log /var/log/nginx/amtest.access.log; | |
error_log /var/log/nginx/amtest.error.log warn; | |
#error_page 404 /index.php; | |
# File uploads (default 1MB) | |
client_max_body_size 20M; | |
sendfile off; | |
############## | |
# Koken | |
############## | |
## Rewrite Rules (Pretty URLs) | |
## These rules remove index.php/ from your published site links | |
## and also speed up the serving of cached images. | |
# By default, do not set expire headers | |
expires 0; | |
# Set expires header for console CSS and JS. | |
# These files are timestamped with each new release, so it is safe to cache them agressively. | |
location ~ "console_.*\.(js|css)$" { | |
expires max; | |
} | |
# Pass images requests back to PHP if they do not exist | |
location ~ "^/storage/cache/images(/(([0-9]{3}/[0-9]{3})|custom)/.*)$" { | |
expires max; | |
try_files $uri /i.php?path=$1; | |
} | |
# Pass albums requests back to PHP if they do not exist | |
location ~ "^/storage/cache/albums(/([0-9]{3}/[0-9]{3})/.*)$" { | |
expires max; | |
try_files $uri /a.php?path=$1; | |
} | |
# Standard site requests are cached with .html extensions | |
set $cache_ext 'html'; | |
# PJAX requests contain the _pjax GET parameter and are cached with .phtml extensions | |
if ($arg__pjax) { | |
set $cache_ext 'phtml'; | |
} | |
# Do not check for a cache for non-GET requests | |
if ($request_method != 'GET') { | |
set $cache_ext 'nocache'; | |
} | |
# Catch root requests | |
location ~ ^/?$ { | |
try_files /storage/cache/site/index/cache.$cache_ext /app/site/site.php?url=/; | |
} | |
# catch site requests | |
location / { | |
try_files $uri $uri/ /storage/cache/site/${uri} /storage/cache/site/${uri}cache.$cache_ext /app/site/site.php?url=$uri&$args; | |
} | |
########### | |
# end Koken | |
########### | |
# PHP config - check your server | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/run/php/php7.0-fpm.sock; | |
fastcgi_index index.php; | |
include /etc/nginx/fastcgi_params; | |
} | |
# clean URLs | |
try_files $uri $uri/ /index.php?$args; | |
# Block download agent | |
if ($http_user_agent ~* LWP::Simple|wget|libwww-perl) { | |
return 403; | |
} | |
# Block nasty robots | |
if ($http_user_agent ~ (msnbot|Purebot|Baiduspider|Lipperhey|Mail.Ru|scrapbot) ) { | |
return 403; | |
} | |
# Deny referal spam | |
if ( $http_referer ~* (jewelry|viagra|nude|girl|nudit|casino|poker|porn|sex|teen|babes) ) { | |
return 403; | |
} | |
# Prevent image leeching | |
#location /images/ { | |
# valid_referers none blocked MYDOMAIN.COM; | |
# if ($invalid_referer) { | |
# return 403; | |
# } | |
#} | |
# prevents hidden files (dot files) from being served | |
location ~ /\. { access_log off; log_not_found off; deny all; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment