您好!
是这样的,在配置nginx泛域名的时候,对域名的日志是否记录进行设置,如果是img的二级域名就不做记录,其他的域名的日志就记录下来
location / {
if ($domain ~ ^img$){
access_log off;
}
access_log /home/Www/logs/$http_host.log access;
proxy_pass
http://CAHospital;
}
这样写在location里是可以的,写在location外面就不行了,就想lua能支持if then语句,可不可以实现这个功能?请指点!谢谢!
在 2013-07-17 12:54:23,"Yichun Zhang (agentzh)" <age...@gmail.com> 写道:
>Hello!
>
>2013/7/16 杨进:
>> nginx lua中可以使用if then
>> else语句,它能在location外使用吗?
>
>这是什么意思?Lua 的 if 语句只能在 Lua 代码中使用,和 nginx 的 location 没有关系。或者你是指下面这种用法?
>
> server {
> rewrite_by_lua 'if ... then ... else ... end';
> location ... { ... }
> }
>
>你能表述得更具体一些么?
>
>> 还有在nginx中如果只使用lua的if语句而不使用rewrite模块中的if语句,这样在nginx配置中可以吗?
>
>为什么不可以?这是推荐的做法。因为 ngx_rewrite 模块的 if 有很多使用上的陷讲,见这里:
>
> http://wiki.nginx.org/IfIsEvil
>
>> 是不是要用到lua中的if只有在nginx配置调用lua的语句的时候才能用到?
>>
>
>是的,当然。
>
>nginx.conf 配置文件有自己语法,独立于 Lua 语言。推荐阅读我的 nginx 连载教程:
>
> http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
>
>Regards,
>-agentzh
>
>--
>--
>邮件来自列表“openresty”,专用于技术讨论!
>订阅: 请发空白邮件到 openresty+subscribe@googlegroups.com
>发言: 请发邮件到 openresty@googlegroups.com
>退订: 请发邮件至 openresty+unsubscribe@googlegroups.com
>归档: http://groups.google.com/group/openresty
>官网: http://openresty.org/
>仓库: https://github.com/agentzh/ngx_openresty
>教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
>
>