【发布时间】:2021-12-04 11:21:00
【问题描述】:
试图了解 Yaws 和我的 docker 堆栈。
我在yaws.conf 中有 3 台服务器:domain.tld、my.domain.tld 和 sm.domain.tld。这些对应于容器www、wmy 和wsm。我希望 Yaws 通过 appmod 处理来自domain.tld 的数据并通过其他两个。
使用nginx 作为代理,这并不难做到。如何正确使用Yaws?
目前我将相同的 appmod 传递给所有三个,然后让该 appmod 决定要做什么。
out_check_glue(A) ->
{url, Scheme, Host, _Port , Path, Querypart} = yaws_api:request_url(A),
case Host of
"my.domain.tld" ->
Url = "http://" ++ "wmy" ++ Path ++ get_query(Querypart),
?trace('out_check_glue(A)==++++++++++++++++++++++++++++++++++=========CALL WMY============> Url', [Url]),
vx_request_url(Url);
"sm.domain.tld" ->
Url = "http://" ++ "wsm" ++ Path ++ get_query(Querypart),
?trace('out_check_glue(A)==++++++++++++++++++++++++++++++++++=========CALL WSM============> Url', [Url]),
vx_request_url(Url);
_ ->
?trace('out_check_glue(A)==++++++++++++++++++++++++++++++++++=========NO GLUE============> Scheme, Host,Path,Querypart', [io:format("~n~n~n~p~n", ["WE START HERE out_check_glue"]),Scheme, Host,Path,Querypart]),
out_vx(A)
end.
vx_request_url 只是调用httpc:request 并进行一些进一步的区分,例如容器adm,正如在别处讨论的那样,所以我在这里有一个简单的传递,out_vx 开始处理www。
这很好用。如您所见,appmod 可以直接调用相应的容器。这也很容易在yaws 容器中复制。进入容器并发出curl http://wmy -- 瞧。
我的想法是完全不涉及 appmod,就像 nginx 的情况一样,并通过重定向将此决定传递给 Yaws,如下所示:
# appmods = </, myurl exclude_paths plugins img images styles scripts>
<redirect>
/ = http://wmy
</redirect>
这不按预期工作:不是容器被调用,而是浏览器必须出错,当然:找不到域wmy。
为什么会这样?有更好的解决方案吗?
【问题讨论】:
-
如果您在尝试
<redirect>方法时包含任何错误输出或日志输出的详细信息,将会很有帮助。 -
好的,谢谢您的解释。我认为您需要在
yaws.conf中安装 3 个虚拟服务器而不是<redirect> ... </redirect>:一个用于包含<revproxy / http://wmy>的my.domain.tld,一个用于包含<revproxy / http://wsm>的sm.domain.tld,然后是带有“无胶水”部分的服务器appmod。 -
听起来很有希望。我究竟做错了什么?
<revproxy / http://wmy>Yaws: bad conf: 意外输入 ['wmy",'>'] 在第 219 行终止 -
抱歉,我给了你错误的语法。应该是
revproxy = / http://wmy