简体   繁体   English

yaws 因 httpc:request for URL 由 docker 容器而崩溃

[英]yaws crashes with httpc:request for URL served by docker container

I use yaws and adminer in my docker stack.我在我的adminer堆栈中使用yawsadminer Formerly, I used to route https://mydomain.tld/adm?foo=bar with nginx to the proper container via以前,我曾经通过nginxhttps://mydomain.tld/adm?foo=bar路由到适当的容器

    location /adm/ {
        proxy_pass         http://adm:8080;
    }

How to do that in yaws ?如何在yaws做到这一点?

The idea is to get the result from the container adm directly.这个想法是直接从容器adm获取结果。 Entering the yaws container and issuing curl -v 'http://adm:8080' works as expected.进入yaws容器并发出curl -v 'http://adm:8080'按预期工作。

My Erlang code is straightforward, but I get an error I cannot make sense of.我的 Erlang 代码很简单,但出现了一个我无法理解的错误。 I start with parsing the URL for adm and if true translate the URL from https://mydomain.tld/adm?foo=bar to http://adm:8080?foo=bar and then call out_adm我首先解析adm的 URL,如果为 true,则将 URL 从https://mydomain.tld/adm?foo=barhttp://adm:8080?foo=bar ,然后调用out_adm

out_adm(Url, A) ->
    inets:start(),
    Http_result = httpc:request(Url),
    case Http_result of
        {ok, {{_Version, 200, _ReasonPhrase}, _Headers, Html}} ->               
?trace('out_check_adm(A)======PASS_THROUGH HTML====> Url', [Url]),  
                    Html; 
        _ -> 
            not_200 
    end.

With the help of trace I know that Http_result is ok with Status 200.在跟踪的帮助下,我知道Http_resultStatus 200 一致。

Mod:myurl line:863 'out_adm(A)=====PASS_THROUGH HTML====> Url' ["http://adm:8080"]
=ERROR REPORT==== 11-Oct-2021::17:55:28.784448 ===
yaws code at appmod:0 crashed or ret bad val:60
Req: {http_request,'GET',{abs_path,"/adm"},{1,1}}

I'm left with no clue.我一无所知。 To me all is clear and easy, hence the error comes as a surprise.对我来说,一切都很简单明了,因此错误出人意料。 What is the problem?问题是什么? How can I understand the error message?我如何理解错误信息? Is something wrong with Html ? Html有什么问题吗? If so, what?如果是这样,是什么?

Looking at the definition inhttps://github.com/erlyaws/yaws/blob/master/src/yaws_server.erl did not help me:查看https://github.com/erlyaws/yaws/blob/master/src/yaws_server.erl中的定义对我没有帮助:

handle_out_reply(Reply, LineNo, YawsFile, _UT, ARG) ->
    L =  ?F("yaws code at ~s:~p crashed or "
            "ret bad val:~p ~nReq: ~p",
            [YawsFile, LineNo, Reply, ARG#arg.req]),
    handle_crash(ARG, L).

How can I debug this?我该如何调试? Is this a problem of docker or yaws ?这是docker还是yaws的问题?

Found my error:发现我的错误:

Instead of a simple Html;而不是一个简单的Html; in my out_adm function it has to be {html, Html};在我的out_adm函数中,它必须是{html, Html};

But now I face another problem: See HTML is not applying the CSS when viewed in browser但现在我面临另一个问题: 在浏览器中查看时,请参阅HTML 未应用 CSS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM