Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evemilano/4164b0b4c920c9f77b84630fbbd724b9 to your computer and use it in GitHub Desktop.
Save evemilano/4164b0b4c920c9f77b84630fbbd724b9 to your computer and use it in GitHub Desktop.
Configurazione Virtual Host Nginx evemilano.com
fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
# 201803 aggiunto
add_header X-Cache $upstream_cache_status;
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name www.evemilano.com evemilano.com;
return 301 https://www.evemilano.com$request_uri;
}
# redirect IP
server {
listen 80;
server_name 82.196.0.237;
return 301 $scheme://www.evemilano.com$request_uri;
}
server {
# Gestione SSL
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
server_name www.evemilano.com evemilano.com;
# mappatura redirect in file esterno
include /etc/nginx/.redirects;
# disable xmlrpc
location = /xmlrpc.php {
deny all;
access_log off;
log_not_found off;
}
## root
root /home/giovanni/www/www.evemilano.com/;
## Log
access_log /var/log/nginx/evemilano_access.log;
#access_log /home/giovanni/www/www.evemilano.com/log/evemilano_access.log;
error_log /var/log/nginx/evemilano_error.log warn;
index index.php index.html index.htm;
#Cache everything by default
set $skip_cache 0;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
# Don't cache uris containing the following segments
if ($request_uri ~* "/keyword-tool/|/wp-admin/|/sw.js|/manifest.json|/xmlrpc.php|wp-.*.php|/feed/|socialcounter.php|index.php|robots.txt|sitemap(_index)?.xml") {
set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
# Enable Gzip
gzip on;
gzip_comp_level 5;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types
application/atom+xml
application/javascript
application/json
application/ld+json
application/manifest+json
application/rss+xml
application/vnd.geo+json
application/vnd.ms-fontobject
application/x-font-ttf
application/x-web-app-manifest+json
application/xhtml+xml
application/xml
font/opentype
image/bmp
image/svg+xml
image/x-icon
text/cache-manifest
text/css
text/plain
text/vcard
text/vnd.rim.location.xloc
text/vtt
text/x-component
text/x-cross-domain-policy;
# Googwords Symfony2
rewrite ^/keyword-tool/app\.php/?(.*)$ /keyword-tool/$1 permanent;
location /keyword-tool/ {
fastcgi_no_cache 1;
index app.php;
try_files $uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)$ /keyword-tool/app.php/$1 last;
}
# pass the PHP scripts to FastCGI server from upstream phpfcgi
location ~ ^/keyword-tool/(app|app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# NO-CACHE TECH STUFF
location ~* \.(manifest|appcache|html?|xml|txt|json)$ {
expires -1;
access_log off;
log_not_found off;
etag on;
}
# caching CSS JS
location ~* \.(css|js)$ {
expires 365d;
add_header Cache-Control "public";
etag on;
}
# caching FONTS
location ~* \.(eot|woff|ttf)$ {
expires 365d;
access_log off;
log_not_found off;
add_header Cache-Control "public";
etag on;
}
# caching IMAGES
location ~* \.(jpg|jpeg|bmp|gif|webp|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 365d;
access_log off;
log_not_found off;
add_header Cache-Control "public";
etag on;
}
#uploaded files
rewrite ^(.*)?/?files/(.*) /wp-content/blogs.php?file=$2;
rewrite ^.*/files/(.*) /wp-content/blogs.php?file=$1;
#abilita permalink wordpress
location / {
try_files $uri $uri/ /index.php?$args;
}
# Pass all .php files onto a php-fpm/php-fcgi server.
location ~ \.php$ {
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;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 200 60m;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment