全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 3784|回复: 20
打印 上一主题 下一主题

啊~终于折腾完了Wordpress+Varnish+Apache

[复制链接]
跳转到指定楼层
1#
发表于 2011-12-10 23:46:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Wordpress+Varnish+Apache,废了nginx。
演示地址在签名,一会发方法....

[ 本帖最后由 母‪鸡 于 2011-12-10 23:48 编辑 ]

评分

参与人数 2威望 +24 收起 理由
lazyzhu + 20 精品文章
四师兄 + 4

查看全部评分

2#
发表于 2011-12-10 23:47:32 | 只看该作者
前排
3#
发表于 2011-12-10 23:49:22 | 只看该作者
不快啊
4#
发表于 2011-12-10 23:49:40 | 只看该作者
挺快的
5#
发表于 2011-12-10 23:50:03 | 只看该作者
Server: nginx/1.1.10
Date: Sat, 10 Dec 2011 15:48:43 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 10425
Connection: keep-alive
X-Powered-By: PHP/5.3.3-7+squeeze3
X-Pingback: http://www.0day.la/xmlrpc.php
Vary: Accept-Encoding
X-Cacheable: YES
X-Varnish: 1880677704
Age: 0
Via: 1.1 varnish
6#
发表于 2011-12-10 23:50:50 | 只看该作者
原来放锅内的。
7#
 楼主| 发表于 2011-12-10 23:51:36 | 只看该作者
以下内容是debian系统下的方法,其他系统自己看着办。。。:
apt-get install varnish
以下规则针对wordpress
  1. backend default {
  2.     .host = "127.0.0.1";
  3.     .port = "apache后端端口";
  4. }
  5. acl purge{
  6. "127.0.0.1";
  7. }
  8. sub vcl_fetch {
  9.     if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$") {
  10.             unset beresp.http.set-cookie;
  11.             set beresp.ttl   = 24h;
  12.     }

  13.     if (req.http.Cookie ~"(wp-postpass|wordpress_logged_in|comment_author_)") {
  14.         set beresp.cacheable = false;
  15.     } else {
  16.         set beresp.cacheable = true;
  17.     }
  18.     if (!beresp.cacheable) {
  19.         set beresp.http.X-Cacheable = "NO:Not Cacheable";
  20.     } else if ( req.http.Cookie ~"(wp-postpass|wordpress_logged_in|comment_author_)" ) {
  21.         set beresp.http.X-Cacheable = "NO:Got Session";
  22.         return(pass);
  23.     }  else if ( beresp.http.Cache-Control ~ "private") {
  24.         set beresp.http.X-Cacheable = "NO:Cache-Control=private";
  25.         return(pass);
  26.     } else if ( beresp.ttl < 1s ) {
  27.         set beresp.ttl   = 300s;
  28.         set beresp.grace = 300s;
  29.         set beresp.http.X-Cacheable = "YES:Forced";
  30.     } else {
  31.         set beresp.http.X-Cacheable = "YES";
  32.     }
  33.     if (beresp.status == 404 || beresp.status >= 500) {
  34.         set beresp.ttl = 0s;
  35.     }

  36.     return(deliver);
  37. }

  38. sub vcl_hash {
  39.     if ( req.http.Cookie ~"(wp-postpass|wordpress_logged_in|comment_author_)" ) {
  40.         set req.hash += req.http.Cookie;
  41.     }
  42. }

  43. # Deliver
  44. sub vcl_deliver {
  45. }
  46. sub vcl_recv {
  47.     set req.url = regsub(req.url, "\?ver=.*$", "");
  48.     set req.url = regsub(req.url, "\?replytocom=.*$", "");

  49.     remove req.http.X-Forwarded-For;
  50.     set    req.http.X-Forwarded-For = client.ip;
  51.     set req.grace = 120s;
  52.     if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$") {
  53.         unset req.http.Cookie;
  54.         return(lookup);
  55.     }
  56.     set req.http.Cookie = regsuball(req.http.Cookie, "(^|;\s*)(__[a-z]+|has_js)=[^;]*", "");
  57.     set req.http.Cookie = regsub(req.http.Cookie, "^;\s*", "");
  58.     if (req.http.Cookie ~ "^\s*$") {
  59.         unset req.http.Cookie;
  60.     }
  61.     if (req.request == "PURGE") {
  62.         if (!client.ip ~ purge) {
  63.                 error 405 "Not allowed.";
  64.         }
  65.         purge("req.url ~ " req.url " && req.http.host == " req.http.host);
  66.         error 200 "Purged.";
  67.     }
  68.     if (req.request != "GET" && req.request != "HEAD") {
  69.         return( pass );
  70.     }      /* We only deal with GET and HEAD by default */

  71.     set req.http.cookie = regsub(req.http.cookie, "1231111111111111122222222333333=[^;]+(; )?", "");
  72.      if (req.request == "GET" && (req.url ~ "(wp-admin)")) {
  73.         return(pipe);
  74.     }
  75.     if (req.http.Cookie && req.http.Cookie ~ "(wordpress_|PHPSESSID)") {
  76.         return(pass);
  77.     }
  78.     if(req.http.X-Requested-With == "XMLHttpRequest" || req.url ~ "nocache" || req.url ~ "(wp-comments-post.php|wp-login.php)") {
  79.         return (pass);
  80.     }
  81.     return( lookup );
  82. }
复制代码
这是varnish的配置,等我吃点东西再发wordpress代码改造。。

评分

参与人数 1威望 +4 收起 理由
四师兄 + 4 学习

查看全部评分

8#
发表于 2011-12-10 23:52:28 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
9#
 楼主| 发表于 2011-12-10 23:52:32 | 只看该作者

回复 5# 杀杀杀 的帖子

恩,那个nginx是在win上的,反向代理到我的虚拟linux机器
原因见这http://mjj.567899.xyz/thread-92719-1-1.html
10#
发表于 2011-12-10 23:55:41 | 只看该作者
主席你好,主席再见
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2026-5-1 14:18 , Processed in 0.066516 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表