location / {
proxy_pass http://govoluble;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf|js|css)\?v=.+$
{
keepalive_timeout 30;
expires 365d;
access_log off;
}
上面是配置,然后我访问
/css/css.css?v=1asd
结果看了一下nginx 的日志,
2015/04/30 11:01:21 [debug] 12224#10940: *1 http request line: "GET /css/css.css?v=1asd HTTP/1.1"
2015/04/30 11:01:21 [debug] 12224#10940: *1 http uri: "/css/css.css"
2015/04/30 11:01:21 [debug] 12224#10940: *1 http args: "v=1asd"
2015/04/30 11:01:21 [debug] 12224#10940: 1 test location: "/"
2015/04/30 11:01:21 [debug] 12224#10940: *1 test location: ~ "..(gif|jpg|jpeg|png|bmp|swf|js|css)\?v=.+$"
2015/04/30 11:01:21 [debug] 12224#10940: *1 using configuration "/"
location / 被匹配成功了,而那个正则的却没有,请问这是哪里 写错了啊?
1
shshilmh 2015-04-30 12:43:35 +08:00
.要转义
|
2
ryd994 2015-04-30 14:51:01 +08:00 1
location不带get参数
|
3
ryd994 2015-04-30 14:52:34 +08:00
location ~* .*\.(gif|jpg|jpeg|png|bmp|swf|js|css) {
} |