问题:我正在尝试自定义由kong生成的nginx配置,以提供静态内容以及我的api as described here。我可以生成nginx.conf
文件,但是为了我的生命-我无法提供简单的HTML。
我所做的事情:我创建了一个最小的docker-compose
,用于重现我的问题here。我在这里尝试了各种组合,并且普遍得到相同的结果:
{"message":"no Route matched with those values"}
我看到的唯一相关日志是:
2020/04/04 06:20:11 [warn] 49#0: *11361 using uninitialized "kong_proxy_mode" variable, client: 127.0.0.1, server: kong, request: "GET /index.html HTTP/1.1", host: "localhost:8000"
2020/04/04 06:20:11 [warn] 49#0: *11361 using uninitialized "ctx_ref" variable, client: 127.0.0.1, server: kong, request: "GET /index.html HTTP/1.1", host: "localhost:8000"
2020/04/04 06:20:11 [warn] 49#0: *11361 [lua] reports.lua:75: log(): [reports] unknown request scheme: http while logging request, client: 127.0.0.1, server: kong, request: "GET /index.html HTTP/1.1", host: "localhost:8000"
我尝试使用root
而非location
将alias
从root
中移出,传递主机标头,更改server_name
,其他我不记得的东西。
我相信问题出在here,但目前我还不知道。我认为这是问题所在,因为如果将正文更改为:
location / {
return 200 'huh?';
}
任何帮助都会使我的生活重拾几年。
编辑
我stripped out everything除了location /
和location /api/
的基本要点外,这是可行的-因此,我可以尝试从这里开始寻找原因。
编辑 似乎this commit包含重大更改,但我不清楚该重大更改是什么。
答案 0 :(得分:0)
我能够找出问题所在,事后看来很明显。这些kong指令只需要放在api的location块内,而不是静态内容。
rewrite_by_lua_block {
Kong.rewrite()
}
access_by_lua_block {
Kong.access()
}
header_filter_by_lua_block {
Kong.header_filter()
}
body_filter_by_lua_block {
Kong.body_filter()
}
log_by_lua_block {
Kong.log()
}
查看已解决问题here
的提交