【发布时间】:2017-04-17 14:14:58
【问题描述】:
我们使用 kong 作为我们的 API 网关,并且有一些端点需要超过 60 秒才能响应。根据 Nginx documentation,我可以用proxy_read_timeout 更改此设置,但此设置没有任何影响,我不知道为什么。
我们使用 kong 作为 docker 容器。这是Dockerfile的摘录
FROM mashape/kong:0.9.5
COPY nginx.conf.custom /usr/local/kong/nginx.conf.custom
COPY nginx-kong.conf.custom /usr/local/kong/nginx-kong.conf.custom
...
我们的 nginx-kong.conf.custom 文件除了下面的摘录之外与默认文件相同,在位置 / 块中。
location / {
set $upstream_host nil;
set $upstream_url nil;
access_by_lua_block {
kong.access()
}
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $upstream_host;
proxy_pass_header Server;
proxy_pass $upstream_url;
proxy_read_timeout 180s;
proxy_connect_timeout 75s;
header_filter_by_lua_block {
kong.header_filter()
}
body_filter_by_lua_block {
kong.body_filter()
}
log_by_lua_block {
kong.log()
}
}
【问题讨论】: