小编Spy*_*dis的帖子

nginx if 语句在 location 中返回 404

下面的块

location / {
    if ($http_origin ~* (https?://[^/]*\.example\.com(:[0-9]+)?)) {
        add_header 'Access-Control-Allow-Origin' "$http_origin";
    }
    try_files $uri $uri/ /index.php?$args;
}
Run Code Online (Sandbox Code Playgroud)

… 导致 404,因为上面的代码永远不会到达try_files指令,所以:

  1. 这与nginx的IfIsEvil有关吗?

  2. 如果是,那么是否有其他方法可以http_origin通过不使用 if 语句来测试?

我已经用 nginx > 1.4 (1.4.6, 1.7, 1.7.8) 试过了。

nginx cors

11
推荐指数
1
解决办法
5261
查看次数

puppet onlyif with pgrep 不起作用

只有当它的进程没有运行时,我才想在 puppet 中使用 exec

exec { "execute me":
    onlyif  => "pgrep -fc 'ruby execute.rb'",  
    command => "execute me",
}
Run Code Online (Sandbox Code Playgroud)

因此,在上述情况下,如果进程 'ruby execute.rb' 已经在运行,则 exec 不应作为

pgrep -fc 'ruby execute.rb' will return 1.
Run Code Online (Sandbox Code Playgroud)

然而

该命令似乎总是在 puppet 中运行。

在我的 linux 机器上,当我执行 pgrep -fc 'ruby execute.rb' 时,我总是得到大于 0 的值。

我的命令有问题吗?

linux puppet pgrep

3
推荐指数
1
解决办法
2067
查看次数

标签 统计

cors ×1

linux ×1

nginx ×1

pgrep ×1

puppet ×1