我意识到我的nginx服务器无法找到它拥有的文件
使用此链接
http://i-health.cc/wp-content/themes/Avada/framework/plugins/LayerSlider/js/jquery-easing-1.3.js
但如果我将文件名更改为jquery-easing-1.3-x.js并且我可以看到该文件?
是否有一些重写机制会影响这个?
我正在使用Varnish + nginx + php-fpm + wordpress这个设置: http://calendar.perfplanet.com/2012/using-nginx-php-fpmapc-and-varnish-to-make-wordpress-websites-fly/
有人可以告诉我该怎么做才能让它发挥作用?
韩国社交协会
server {
# Default server block blacklisting all unconfigured access
listen [::]:8080 default_server;
server_name _;
return 444;}
server {
# Configure the domain that will run WordPress
server_name i-health.cc;
listen [::]:8080 deferred;
port_in_redirect off;
server_tokens off;
autoindex off;
client_max_body_size 15m;
client_body_buffer_size 128k;
# WordPress needs to be in the webroot of /var/www/ in this case
root /var/www/html;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
# Define default caching of 24h
expires 86400s;
add_header Pragma public;
add_header Cache-Control "max-age=86400, public, must-revalidate, proxy-revalidate";
# deliver a static 404
error_page 404 /404.html;
location /404.html {
internal;
}
# Deliver 404 instead of 403 "Forbidden"
error_page 403 = 404;
# Do not allow access to files giving away your WordPress version
location ~ /(\.|wp-config.php|readme.html|licence.txt) {
return 404;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
# Don't log robots.txt requests
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Rewrite for versioned CSS+JS via filemtime
location ~* ^.+\.(css|js)$ {
rewrite ^(.+)\.(\d+)\.(css|js)$ $1.$3 last;
expires 31536000s;
access_log off;
log_not_found off;
add_header Pragma public;
add_header Cache-Control "max-age=31536000, public";
}
# Aggressive caching for static files
# If you alter static files often, please use
# add_header Cache-Control "max-age=31536000, public, must-revalidate, proxy-revalidate";
location ~* \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|odb|odc|odf|odg|odp|ods|odt|ogg|ogv|otf|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|t?gz|tif|tiff|ttf|wav|webm|wma|woff|wri|xla|xls|xlsx|xlt|xlw|zip)$ {
expires 31536000s;
access_log off;
log_not_found off;
add_header Pragma public;
add_header Cache-Control "max-age=31536000, public";
}
# pass PHP scripts to Fastcgi listening on Unix socket
# Do not process them if inside WP uploads directory
# If using Multisite or a custom uploads directory,
# please set the */uploads/* directory in the regex below*/
location ~* (^(?!(?:(?!(php|inc)).)*/uploads/).*?(php)) {
try_files $uri = 404;
fastcgi_split_path_info ^(.+.php)(.*)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
# Deny access to hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
}
# Redirect all www. queries to non-www
# Change in case your site is to be available at "www.yourdomain.tld"
server {
listen [::]:8080;
server_name www.i-health.cc;
rewrite ^ $scheme://i-health.cc$request_uri? permanent;
}
varnish conf:
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 10s;
.first_byte_timeout = 30s;
.between_bytes_timeout = 1s;
}
# Only allow purging from specific IPs
acl purge {
"localhost";
"127.0.0.1";
}
sub vcl_recv {
if (req.http.Accept-Encoding) {
if (req.http.Accept-Encoding ~ "gzip") {
# If the browser supports it, we'll use gzip.
set req.http.Accept-Encoding = "gzip";
}
else if (req.http.Accept-Encoding ~ "deflate") {
# Next, try deflate if it is supported.
set req.http.Accept-Encoding = "deflate";
}
else {
# Unknown algorithm. Remove it and send unencoded.
unset req.http.Accept-Encoding;
}
}
# Set client IP
if (req.http.x-forwarded-for) {
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
} else {
set req.http.X-Forwarded-For = client.ip;
}
# Check if we may purge (only localhost)
if (req.request == "PURGE") {
if (!client.ip ~ purge) {
error 405 "Not allowed.";
}
ban("req.url ~ "+req.url);
error 200 "Purged";
}
if (req.request != "GET" &&
req.request != "HEAD" &&
req.request != "PUT" &&
req.request != "POST" &&
req.request != "TRACE" &&
req.request != "OPTIONS" &&
req.request != "DELETE") {
# /* Non-RFC2616 or CONNECT which is weird. */
return (pipe);
}
if (req.request != "GET" && req.request != "HEAD") {
# /* We only deal with GET and HEAD by default */
return (pass);
}
# admin users always miss the cache
if( req.url ~ "^/wp-(login|admin)" ||
req.http.Cookie ~ "wordpress_logged_in_" ){
return (pass);
}
# Remove cookies set by Google Analytics (pattern: '__utmABC')
if (req.http.Cookie) {
set req.http.Cookie = regsuball(req.http.Cookie,
"(^|; ) *__utm.=[^;]+;? *", "\1");
if (req.http.Cookie == "") {
remove req.http.Cookie;
}
}
# always pass through POST requests and those with basic auth
if (req.http.Authorization || req.request == "POST") {
return (pass);
}
# Do not cache these paths
if (req.url ~ "^/wp-cron\.php$" ||
req.url ~ "^/xmlrpc\.php$" ||
req.url ~ "^/wp-admin/.*$" ||
req.url ~ "^/wp-includes/.*$" ||
req.url ~ "\?s=") {
return (pass);
}
# Define the default grace period to serve cached content
set req.grace = 30s;
# By ignoring any other cookies, it is now ok to get a page
unset req.http.Cookie;
return (lookup);
}
sub vcl_fetch {
# remove some headers we never want to see
unset beresp.http.Server;
unset beresp.http.X-Powered-By;
# only allow cookies to be set if we're in admin area
if( beresp.http.Set-Cookie && req.url !~ "^/wp-(login|admin)" ){
unset beresp.http.Set-Cookie;
}
# don't cache response to posted requests or those with basic auth
if ( req.request == "POST" || req.http.Authorization ) {
return (hit_for_pass);
}
# don't cache search results
if( req.url ~ "\?s=" ){
return (hit_for_pass);
}
# only cache status ok
if ( beresp.status != 200 ) {
return (hit_for_pass);
}
# If our backend returns 5xx status this will reset the grace time
# set in vcl_recv so that cached content will be served and
# the unhealthy backend will not be hammered by requests
if (beresp.status == 500) { set beresp.grace = 60s;
return (restart);
}
# GZip the cached content if possible
if (beresp.http.content-type ~ "text") {
set beresp.do_gzip = true;
}
# if nothing abovce matched it is now ok to cache the response
set beresp.ttl = 24h;
return (deliver);
}
sub vcl_deliver {
# remove some headers added by varnish
unset resp.http.Via;
unset resp.http.X-Varnish;
}
sub vcl_hit {
# Set up invalidation of the cache so purging gets done properly
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
return (deliver);
}
sub vcl_miss {
# Set up invalidation of the cache so purging gets done properly
if (req.request == "PURGE") {
purge;
error 200 "Purged.";
}
return (fetch);
}
sub vcl_error {
if (obj.status == 503) {
# set obj.http.location = req.http.Location;
set obj.status = 404;
set obj.response = "Not Found";
return (deliver);
}
}
这是nginx错误消息
2013/08/05 10:20:13 [error] 3050#0: *7 open() "/var/www/html/404.html" failed (2: No such file or directory), client: 54.239.129.205, server: i-health.cc, request: "GET /wp-content/themes/Avada/framework/plugins/LayerSlider/js/jquery-easing-1.3.js HTTP/1.1", host: "i-health.cc"