如何设置Webhook端点,以便它可以接受HTTPS请求?

发布于 2025-02-10 20:45:49 字数 814 浏览 0 评论 0原文

我正在尝试设置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:enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魂牵梦绕锁你心扉 2025-02-17 20:45:49

可以使用Apache 使用 SSL终止解决此问题。您基本上将其充当反向代理,该代理在https://example.com/webhook上转发任何内容to http:// 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 to http://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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文