-
-
Save eksiscloud/654a954dc4ed876fefe8c0ac4999fdda to your computer and use it in GitHub Desktop.
/etc/nginx/sites-available/eksis.dev with cache of Nginx
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
fastcgi_cache_path /var/www/eksis.dev/cache levels=1:2 keys_zone=eksis.dev:100m inactive=60m; | |
server { | |
listen 161.35.23.171:443 ssl http2; | |
server_name eksis.dev www.eksis.dev; | |
root /var/www/eksis.dev/public_html/; | |
index index.php; | |
ssl_certificate /etc/letsencrypt/live/eksis.dev/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/eksis.dev/privkey.pem; | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
if ($host = eksis.dev) { | |
return 301 https://www.$host$request_uri; | |
} | |
# Webistä ei koskaan saa päästä wp-config.php tiedostoihin | |
location ~* wp-config.php { | |
access_log /var/log/nginx/blocked.log blocked; | |
deny all; | |
} | |
# xmlrpc saisi olla sallittuna vain harvoille. | |
location ~* xmlrpc.php { | |
access_log /var/log/nginx/blocked.log blocked; | |
allow 192.168.0.1; | |
deny all; | |
} | |
# Harmittomia tiedostoja, mutta kertovat aukkoja etsivälle suoraan | |
# onko jokin asennettu ja mikä sen versio on. | |
location ~* (licence|readme|license)\.(html|txt) { | |
access_log /var/log/nginx/blocked.log blocked; | |
deny all; | |
} | |
set $skip_cache 0; | |
# POST pyynnöt eivä saa mennä cacheen | |
if ($request_method = POST) { | |
set $skip_cache 1; | |
} | |
if ($query_string != "") { | |
set $skip_cache 1; | |
} | |
# Näitä ei laiteta välimuistiin | |
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") { | |
set $skip_cache 1; | |
} | |
# Sisäänkirjautuneita tai Wordpressin kommentteja ei laiteta välimuistiin. | |
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { | |
set $skip_cache 1; | |
} | |
# Woocommercen perussivuja ei laiteta välimuistiin | |
if ($request_uri ~* "/(cart|checkout|my-account)/*$") { | |
set $skip_cache 1; | |
} | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/run/php/php7.4-fpm.sock; | |
include fastcgi_params; | |
include snippets/fastcgi-php.conf; | |
# cacheen liittyvät | |
fastcgi_cache_bypass $skip_cache; | |
fastcgi_no_cache $skip_cache; | |
fastcgi_cache eksis.dev; | |
fastcgi_cache_valid 60m; | |
} | |
} | |
server { | |
listen 161.35.23.171:80; | |
server_name eksis.dev www.eksis.dev; | |
access_log /var/log/nginx/access-80.log; | |
error_log /var/log/nginx/error-80.log; | |
if ($host = www.eksis.dev) { | |
return 301 https://$host$request_uri; | |
} | |
if ($host = eksis.dev) { | |
return 301 https://www.$host$request_uri; | |
} | |
return 404; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment