V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  RiESA  ›  全部回复第 24 页 / 共 60 页
回复总数  1195
1 ... 20  21  22  23  24  25  26  27  28  29 ... 60  
2020-02-23 18:52:21 +08:00
回复了 hxse 创建的主题 问与答 有没有一款支持 WYSIWYG(所见即所得)的跨平台 markdown 云笔记
马克飞象
下一个丸子工具箱自己压了再上传
2020-02-19 15:01:01 +08:00
回复了 turlin 创建的主题 生活 经过了这次 才知道指纹解锁还是香啊
两个一起用不好吗?
vcl 4.0;
# set default backend if no server cluster specified
backend default {
.host = "127.0.0.1";
.port = "80";
}
backend test {
.host = "127.0.0.1";
.port = "81";
}


# access control list for "purge": open to only localhost and other local nodes
acl purge {
"127.0.0.1";
}

# vcl_recv is called whenever a request is received
sub vcl_recv {
# Serve objects up to 2 minutes past their expiry if the backend
# is slow to respond.
# set req.grace = 120s;
if(req.http.host ~ "a.cn"){
set req.http.host = "a.cn";
set req.backend_hint = default;
}
if(req.http.host ~ "b.cn"){
set req.http.host = "b.cn";
set req.backend_hint = test;
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
set req.backend_hint= default;

# This uses the ACL action called "purge". Basically if a request to
# PURGE the cache comes from anywhere other than localhost, ignore it.
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
return (synth(405, "Not allowed."));
} else {
return (purge);
}
}

# Pass any requests that Varnish does not understand straight to the backend.
if (req.method != "GET" && req.method != "HEAD" &&
req.method != "PUT" && req.method != "POST" &&
req.method != "TRACE" && req.method != "OPTIONS" &&
req.method != "DELETE") {
return (pipe);
} /* Non-RFC2616 or CONNECT which is weird. */

# Pass anything other than GET and HEAD directly.
if (req.method != "GET" && req.method != "HEAD") {
return (pass);
} /* We only deal with GET and HEAD by default */

# Pass requests from logged-in users directly.
# Only detect cookies with "session" and "Token" in file name, otherwise nothing get cached.
if (req.http.Authorization || req.http.Cookie ~ "session" || req.http.Cookie ~ "Token") {
return (pass);
} /* Not cacheable by default */

# normalize Accept-Encoding to reduce vary
if (req.http.Accept-Encoding) {
if (req.http.User-Agent ~ "MSIE 6") {
unset req.http.Accept-Encoding;
} elsif (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
unset req.http.Accept-Encoding;
}
}

return (hash);
}


sub vcl_pipe {
# Note that only the first request to the backend will have
# X-Forwarded-For set. If you use X-Forwarded-For and want to
# have it set for all requests, make sure to have:
# set req.http.connection = "close";

# This is otherwise not necessary if you do not do any request rewriting.

set req.http.connection = "close";
}

# Called if the cache has a copy of the page.
sub vcl_hit {
if (!obj.ttl > 0s) {
return (pass);
}

# Force lookup if the request is a no-cache request from the client.
if (req.http.Cache-Control ~ "no-cache") {
return (miss);
}
}

# Called after a document has been successfully retrieved from the backend.
sub vcl_backend_response {
# set minimum timeouts to auto-discard stored objects
set beresp.grace = 120s;

if (beresp.ttl < 48h) {
set beresp.ttl = 48h;
}

if (!beresp.ttl > 0s) {
set beresp.uncacheable = true;
return (deliver);
}

if (beresp.http.Set-Cookie) {
set beresp.uncacheable = true;
return (deliver);
}

# if (beresp.http.Cache-Control ~ "(private|no-cache|no-store)") {
# set beresp.uncacheable = true;
# return (deliver);
# }

if (beresp.http.Authorization && !beresp.http.Cache-Control ~ "public") {
set beresp.uncacheable = true;
return (deliver);
}

return (deliver);
}
更正一下,目前是下面这个才对,上面那个忘记改一个地方了
vcl 4.0;
# set default backend if no server cluster specified
backend default {
.host = "127.0.0.1";
.port = "80";
}
backend test {
.host = "127.0.0.1";
.port = "81";
}


# access control list for "purge": open to only localhost and other local nodes
acl purge {
"127.0.0.1";
}

# vcl_recv is called whenever a request is received
sub vcl_recv {
# Serve objects up to 2 minutes past their expiry if the backend
# is slow to respond.
# set req.grace = 120s;
if(req.http.host ~ "a.com"){
set req.http.host = "a.com";
set req.backend_hint = default;
}
if(req.http.host ~ "b.com"){
set req.http.host = "b.com";
set req.backend_hint = blog;
set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
set req.backend_hint= default;

# This uses the ACL action called "purge". Basically if a request to
# PURGE the cache comes from anywhere other than localhost, ignore it.
if (req.method == "PURGE") {
if (!client.ip ~ purge) {
return (synth(405, "Not allowed."));
} else {
return (purge);
}
}

# Pass any requests that Varnish does not understand straight to the backend.
if (req.method != "GET" && req.method != "HEAD" &&
req.method != "PUT" && req.method != "POST" &&
req.method != "TRACE" && req.method != "OPTIONS" &&
req.method != "DELETE") {
return (pipe);
} /* Non-RFC2616 or CONNECT which is weird. */

# Pass anything other than GET and HEAD directly.
if (req.method != "GET" && req.method != "HEAD") {
return (pass);
} /* We only deal with GET and HEAD by default */

# Pass requests from logged-in users directly.
# Only detect cookies with "session" and "Token" in file name, otherwise nothing get cached.
if (req.http.Authorization || req.http.Cookie ~ "session" || req.http.Cookie ~ "Token") {
return (pass);
} /* Not cacheable by default */

# normalize Accept-Encoding to reduce vary
if (req.http.Accept-Encoding) {
if (req.http.User-Agent ~ "MSIE 6") {
unset req.http.Accept-Encoding;
} elsif (req.http.Accept-Encoding ~ "gzip") {
set req.http.Accept-Encoding = "gzip";
} elsif (req.http.Accept-Encoding ~ "deflate") {
set req.http.Accept-Encoding = "deflate";
} else {
unset req.http.Accept-Encoding;
}
}

return (hash);
}


sub vcl_pipe {
# Note that only the first request to the backend will have
# X-Forwarded-For set. If you use X-Forwarded-For and want to
# have it set for all requests, make sure to have:
# set req.http.connection = "close";

# This is otherwise not necessary if you do not do any request rewriting.

set req.http.connection = "close";
}

# Called if the cache has a copy of the page.
sub vcl_hit {
if (!obj.ttl > 0s) {
return (pass);
}

# Force lookup if the request is a no-cache request from the client.
if (req.http.Cache-Control ~ "no-cache") {
return (miss);
}
}

# Called after a document has been successfully retrieved from the backend.
sub vcl_backend_response {
# set minimum timeouts to auto-discard stored objects
set beresp.grace = 120s;

if (beresp.ttl < 48h) {
set beresp.ttl = 48h;
}

if (!beresp.ttl > 0s) {
set beresp.uncacheable = true;
return (deliver);
}

if (beresp.http.Set-Cookie) {
set beresp.uncacheable = true;
return (deliver);
}

# if (beresp.http.Cache-Control ~ "(private|no-cache|no-store)") {
# set beresp.uncacheable = true;
# return (deliver);
# }

if (beresp.http.Authorization && !beresp.http.Cache-Control ~ "public") {
set beresp.uncacheable = true;
return (deliver);
}

return (deliver);
}
@sleepm 我又来请教您了,我昨晚尝试配置了一下多站点,但是出现了一个很奇怪的问题,站点 A,也就是第一个 backend 完全正常,第二个 backend,站点 B 会出现 404 的情况,但是又不是完全 404 强刷一下页面可以出来,但是没点几下又 404 这种,
目前的访问流程是:CDN>varnish>nginx,不排除是我设置写的有问题,不知道能不能帮我看看,谢谢
@sleepm 好的,谢谢
@sleepm 我是直接 访问>varnish>nginx 这样的结构,前面并没有多一层 nginx,这样的话单纯区分两个站的端口可以解决缓存混淆问题吗?
@sleepm 好的谢谢,我研究一下
打捞一下自己 orz
2020-02-14 00:37:15 +08:00
回复了 waytoshine 创建的主题 生活 一个人,如何解决孤独寂寞这件小事?
2019-09-06 16:21:34 +08:00
回复了 cxy1234 创建的主题 游戏 有没有比较肝的手游
论肝的话,GBF 说第二,有别的游戏敢说第一么
2019-08-30 15:24:30 +08:00
回复了 WenjieYe 创建的主题 随想 突然能理解“有些人能活下去,就已经拼尽全力了”
@nodin #27 说到心坎里了
2019-08-30 15:00:30 +08:00
回复了 WenjieYe 创建的主题 随想 突然能理解“有些人能活下去,就已经拼尽全力了”
2019-08-26 11:08:50 +08:00
回复了 taobibi 创建的主题 CDN 50%国外, 50%国内的业务,应该选择国内 CDN 还是国外 CDN?
国内+国外啊
DNS 那边分线路就行了,国内的解析到国内的 CDN,国外的解析到国外的 CDN,综合下来价格会实惠一点
2019-08-05 16:22:18 +08:00
回复了 MIEason 创建的主题 游戏开发 有人能开发 Roblox 的主题游戏么?
只差一个程序员系列?
会不会 T9?就是之前键盘机的那种打字方法? 电脑上也有类似的输入法,家父就是不会拼音只会这个
2019-07-29 10:41:02 +08:00
回复了 jdhao 创建的主题 程序员 博客中加入 adsense 需要多少访问量才能收支平衡呢?
@GeekCourse #12 感觉还是过于理想化,当然我觉得也和网站的类型有关,不排除是有些站收益高点,自己的站日均 pv 30W,一个月下来 2000 到 3000 块钱不到(RMB)
1 ... 20  21  22  23  24  25  26  27  28  29 ... 60  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1013 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 29ms · UTC 21:48 · PVG 05:48 · LAX 13:48 · JFK 16:48
Developed with CodeLauncher
♥ Do have faith in what you're doing.