<!-- review: finished -->

<a id="external-eval"></a>

# Eval

该模块允许将子请求响应体保存到变量中。

<a id="installation-10"></a>

## 安装

要 [安装](https://cn.angie.software//angie/docs/installation/index.md#install-packages) 该模块，请使用以下软件包之一：

- Angie：`angie-module-eval`
- Angie PRO：`angie-pro-module-eval`

<a id="loading-the-module-10"></a>

## 加载模块

在 `main{}` 上下文中加载模块：

```nginx
load_module modules/ngx_http_eval_module.so;
```

<a id="example-configuration-1"></a>

## 配置示例

```nginx
server {
    listen 80;
    server_name localhost;

    location / {
        eval_subrequest_in_memory off;
        eval_override_content_type text/plain;
        eval_buffer_size 4k;
        eval $res {
            rewrite ^(/eval_.*/)(.*)$  /$2 break;
            proxy_pass http://127.0.0.1:8081;
        }

        if ($res ~ "access denied") {
            return 403 $res\n;
        }

        proxy_pass http://127.0.0.1:8082;
    }
}

server {
    listen 8081;

    if ($arg_user != 'Legal') {
        return 403 "access denied";
    }
    return 200 OK;
}

server {
    listen 8082;

    location / {
        root /usr/share/angie/html;
    }
}
```

<a id="additional-information-11"></a>

## 其他信息

详细文档和源代码可在以下位置获取：
[https://github.com/openresty/nginx-eval-module](https://github.com/openresty/nginx-eval-module)
