nginx HTTP/1.1 502 Bad Gateway

vc6uscn9  于 2023-10-17  发布在  Nginx
关注(0)|答案(1)|浏览(217)

你好,我有问题与oauth。我有一个SSL证书,并按照教程https://www.process-one.net/blog/understanding-ejabberd-oauth-support-roadmap/
我的测试环境是online https://xxxx-chat.de/xmpp-oauth/authorization_token我使用的是ejabinet 23.04 deb
https://xxxx-chat.de/xmpp-oauth/authorization_token上的手动输入也不起作用。
问题出在哪里?

root@v2202308204582236127:~# curl -i -POST 'https://xxxx-chat.de/xmpp-oauth/authorization_token' -d grant_type=password -d [email protected] -d password=NlhOhPiW9159haz3P7FR47QusEkl18cl -d client_id=xxxx-id -d client_secret=sc3dc8b0885b3043c0e38aa2e1dc64sc3dc8b0885b3043c0e38aa2e1dc64 -d scope=ejabberd:admin
HTTP/1.1 502 Bad Gateway
Server: nginx/1.18.0
Date: Thu, 17 Aug 2023 15:02:51 GMT
Content-Type: text/html
Content-Length: 157
Connection: keep-alive

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.18.0</center>
</body>
</html>
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     exception error: no function clause matching
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                      ejabberd_oauth:get_client_identity(<<"client-id-Iegh7ooK">>,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                                                         {oauth_ctx,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                                                          <<"test">>,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                                                          undefined}) (src/ejabberd_oauth.erl, line 248)
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:       in function  oauth2:authorize_password/5 (/home/runner/work/ejabberd/ejabberd/deps/p1_oauth2/src/oauth2.erl, line 120)
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:       in call from ejabberd_oauth:process/2 (src/ejabberd_oauth.erl, line 587)
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:       in call from ejabberd_http:process/2 (src/ejabberd_http.erl, line 375)
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:       in call from ejabberd_http:process_request/1 (src/ejabberd_http.erl, line 505)
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:       in call from ejabberd_http:process_header/2 (src/ejabberd_http.erl, line 294)
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:       in call from ejabberd_http:parse_headers/1 (src/ejabberd_http.erl, line 219)
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:       in call from ejabberd_http:init/3 (src/ejabberd_http.erl, line 143)
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     ancestors: [ejabberd_http_sup,ejabberd_sup,<0.175.0>]
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     message_queue_len: 0
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     messages: []
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     links: [<0.677.0>,#Port<0.92>]
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     dictionary: []
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     trap_exit: false
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     status: running
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     heap_size: 6772
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     stack_size: 28
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     reductions: 25490
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:   neighbours:
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]: 2023-08-17 17:06:21.619778+02:00 [error] SUPERVISOR REPORT:
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     supervisor: {local,ejabberd_http_sup}
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     errorContext: child_terminated
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     reason: {function_clause,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                 [{ejabberd_oauth,get_client_identity,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                      [<<"client-id-Iegh7ooK">>,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                       {oauth_ctx,<<"test">>,undefined}],
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                      [{file,"src/ejabberd_oauth.erl"},{line,248}]},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                  {oauth2,authorize_password,5,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                      [{file,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                           "/home/runner/work/ejabberd/ejabberd/deps/p1_oauth2/src/oauth2.erl"},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                       {line,120}]},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                  {ejabberd_oauth,process,2,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                      [{file,"src/ejabberd_oauth.erl"},{line,587}]},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                  {ejabberd_http,process,2,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                      [{file,"src/ejabberd_http.erl"},{line,375}]},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                  {ejabberd_http,process_request,1,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                      [{file,"src/ejabberd_http.erl"},{line,505}]},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                  {ejabberd_http,process_header,2,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                      [{file,"src/ejabberd_http.erl"},{line,294}]},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                  {ejabberd_http,parse_headers,1,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                      [{file,"src/ejabberd_http.erl"},{line,219}]},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                  {ejabberd_http,init,3,
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                      [{file,"src/ejabberd_http.erl"},{line,143}]}]}
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:     offender: [{pid,<0.1088.0>},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                {id,undefined},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                {mfargs,{ejabberd_http,start_link,undefined}},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                {restart_type,temporary},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                {significant,false},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                {shutdown,5000},
Aug 17 17:06:21 v2202308204582236127 ejabberdctl[34685]:                {child_type,worker}]
7gcisfzg

7gcisfzg1#

快速浏览一下,似乎是很久以前在ejabberd中引入的一个bug,当在HTTP查询中提供client-id时出现。
我现在已经写了一个小补丁https://github.com/badlop/ejabberd/commit/2af40107427e0fd48e7bbe3b7188fdf93da6b2b8
如果你不能自己编译ejabberd,下面有ejabberd 23.04+这个补丁的安装程序包:https://github.com/badlop/ejabberd/actions/runs/5904717152
顺便说一句,你可能还想咨询ejabberd Docs站点中的OAuth页面:https://docs.ejabberd.im/developer/ejabberd-api/oauth/

相关问题