简体   繁体   中英

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

I use yaws and adminer in my docker stack. Formerly, I used to route https://mydomain.tld/adm?foo=bar with nginx to the proper container via

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

How to do that in yaws ?

The idea is to get the result from the container adm directly. Entering the yaws container and issuing curl -v 'http://adm:8080' works as expected.

My Erlang code is straightforward, but I get an error I cannot make sense of. 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

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.

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 ? If so, what?

Looking at the definition inhttps://github.com/erlyaws/yaws/blob/master/src/yaws_server.erl did not help me:

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 ?

Found my error:

Instead of a simple Html; in my out_adm function it has to be {html, Html};

But now I face another problem: See HTML is not applying the CSS when viewed in browser

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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