如何设置Webhook端点,以便它可以接受HTTPS请求?
我正在尝试设置Messenger Webhook端点。 Webhook用node.js编写。 如果没有默认值,则将端点配置为在其默认端口或端口1337
上侦听请求。
app.listen(process.env.PORT || 1337)
问题是我的服务器无法验证回调URL https://example.com/webhook
来自Messenger的请求。这是屏幕截图:
如何将https上的请求重新指向webhook端点。
(我正在使用apache2作为我的http服务器在ubuntu 22.04 lts上运行)
我的设置正在遵循此文档: https://developers.facebook.com/docs/messenger-platform/getting-started/webhook-setup/
I am trying to set-up a Messenger Webhook Endpoint. The Webhook is written with node.js.
The Endpoint is configured to listen for requests on its default port or Port 1337
if there is no default.
app.listen(process.env.PORT || 1337)
The issue is that my server cannot validate the Callback URL https://example.com/webhook
request coming from Messenger. Here is the screenshot:
How do I re-direct the requests coming over https to the webhook endpoint.
(I am using Apache2 as my HTTP server running on Ubuntu 22.04 LTS)
I am following this documentation for my setup: https://developers.facebook.com/docs/messenger-platform/getting-started/webhook-setup/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以使用Apache 使用 SSL终止解决此问题。您基本上将其充当反向代理,该代理在
https://example.com/webhook
上转发任何内容tohttp:// localhost:1337/webhook
。因此有两个部分。 Nodejs将在Localhost:1337和Apache上聆听,并从公共HTTPS转换并将其定位到Nodejs。
Digitalocean的本教程对于在Apache服务器中设置Webhook非常有帮助:
https://www.digitalocean.com/community/tutorials/how-to-to-compace-use-apache-as-a-a-reverse-proxy-with-with-mod-mod_proxy-on-on-ubuntu-16-04
也是如此,此 serverfault问题有助于配置VirtualHost文件。
This problem can be resolved using SSL Termination with Apache. You basically have it act as a reverse proxy that forwards anything on
https://example.com/webhook
tohttp://localhost:1337/webhook
.So there's two parts to this. The NodeJS will listen on localhost:1337 and the Apache translating from public HTTPS and proxying that to NodeJS.
This tutorial by DigitalOcean is very helpful for setting up Webhooks in a Apache Server:
https://www.digitalocean.com/community/tutorials/how-to-use-apache-as-a-reverse-proxy-with-mod_proxy-on-ubuntu-16-04
Also, this ServerFault question helped with configuring VirtualHosts file.