为什么我的Webhook代码无法在HTTPS上访问

劳埃德·阿诺德(Lloyd Arnold)

我正在从在AWS上运行RHEL 8的计算机上运行基于apache2的SSL服务器。我正在尝试在此服务器上部署一个Facebook Webhook。我正在使用curl请求对此进行手动测试。当我通过HTTP将请求放入时,其行为与预期的一样。但是,通过HTTPS发出请求时,出现以下错误消息:

curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number 我需要使其在HTTPS上运行,因为Facebook不允许仅HTTP连接。

谢谢您,任何建议都是令人惊奇的-如果我对此提出的要求很抱歉,这是我的第一个问题。

Webhook的代码如下:


// Imports dependencies and set up http server
const
  express = require('express'),
  bodyParser = require('body-parser'),
  app = express().use(bodyParser.json()); // creates express http server

// Sets server port and logs message on success
app.listen(process.env.PORT || 1337, () => console.log('webhook is listening'));

// Creates the endpoint for our webhook
app.post('/webhook', (req, res) => {

  let body = req.body;

  // Checks this is an event from a page subscription
  if (body.object === 'page') {

    // Iterates over each entry - there may be multiple if batched
    body.entry.forEach(function(entry) {

      // Gets the message. entry.messaging is an array, but
      // will only ever contain one message, so we get index 0
      let webhook_event = entry.messaging[0];
      console.log(webhook_event);
    });

    // Returns a '200 OK' response to all requests
    res.status(200).send('EVENT_RECEIVED');
  } else {
    // Returns a '404 Not Found' if event is not from a page subscription
    res.sendStatus(404);
  }

});

// Adds support for GET requests to our webhook
app.get('/webhook', (req, res) => {

  // Your verify token. Should be a random string.
  let VERIFY_TOKEN = "duckgoesquack"

  // Parse the query params
  let mode = req.query['hub.mode'];
  let token = req.query['hub.verify_token'];
  let challenge = req.query['hub.challenge'];

  // Checks if a token and mode is in the query string of the request
  if (mode && token) {

    // Checks the mode and token sent is correct
    if (mode === 'subscribe' && token === VERIFY_TOKEN) {

      // Responds with the challenge token from the request
      console.log('WEBHOOK_VERIFIED');
      res.status(200).send(challenge);

    } else {
      // Responds with '403 Forbidden' if verify tokens do not match
      res.sendStatus(403);
    }
  }
});

我尝试更新我的apache conf文件-virtualhosts部分如下:

NameVirtualHost *:80

<VirtualHost *:443>
ServerName lloydarnoldtestapps.tk
DocumentRoot /var/www/lloydarnoldtestapps.tk
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/lloydarnoldtestapps.tk/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/lloydarnoldtestapps.tk/privkey.pem
</VirtualHost>

<VirtualHost *:80>
ServerName lloydarnoldtestapps.tk
DocumentRoot /var/www/lloydarnoldtestapps.tk
</VirtualHost>

<VirtualHost *:443>
ServerName www.lloydarnoldtestapps.tk
ServerAlias *.lloydarnoldtestaps.tk
DocumentRoot /var/www/lloydarnoldtestapps.tk
SSLCertificateFile /etc/letsencrypt/live/lloydarnoldtestapps.tk/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/lloydarnoldtestapps.tk/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

<VirtualHost *:1337>
ServerName lloydarnoldtestapps.tk
DocumentRoot /var/www/lloydarnoldtestapps.tk
SSLCertificateFile /etc/letsencrypt/live/lloydarnoldtestapps.tk/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/lloydarnoldtestapps.tk/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>


<VirtualHost *:80>
ServerName www.lloydarnoldtestapps.tk
DocumentRoot /var/www/lloydarnoldtestapps.tk
</VirtualHost>

<VirtualHost *:1337>
ServerName www.lloydarnoldtestapps.tk
DocumentRoot /var/www/lloydarnoldtestapps.tk
SSLCertificateFile /etc/letsencrypt/live/lloydarnoldtestapps.tk/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/lloydarnoldtestapps.tk/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

我想我知道发生了什么事。
curl -vv -X POST https://www.lloydarnoldtestapps.tk回应来自apacheServer: Apache/2.4.37

运行时,curl -vv -X POST http://www.lloydarnoldtestapps.tk:1337/webhook
响应来自快递X-Powered-By: Express

我认为当您首先开始表达并绑定到port 1337apache时,它实际上无法绑定,所以这就是为什么您200port 1337

您不能从apache返回index.js。您将使用apache作为来自AWS(HTTPS)-> Apache(HTTP)-> Express的反向代理和代理请求。这样,Apache将终止https并通过http发出请求以表示。

查看Proxy和ProxyPass中的Apache和反向代理到Node.js服务器的教程。

查看此帖子ProxyPass apache https到节点服务器

特别是这些指令

  ProxyPass / https://example.com:4433/
  ProxyPassReverse / https://example.com:4433 /

如有任何疑问,请发回。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

configatron单身人士?为什么我不能在课堂上访问configatron

来自分类Dev

为什么i ++是“无法访问的代码”?

来自分类Dev

为什么我的代码无法添加活动?

来自分类Dev

为什么我的fstream访问无法编译?

来自分类Dev

为什么我无法在我的手机或其他计算机上访问Rails localhost

来自分类Dev

为什么无法访问的代码在C ++中不是错误?

来自分类Dev

我无法在Xamarin中的代码隐藏上访问Web窗体控件

来自分类Dev

为什么内联访问器会破坏我的代码?

来自分类Dev

为什么此代码警告在Groovy中无法访问?

来自分类Dev

为什么我的代码无法访问?

来自分类Dev

为什么我的代码无法访问刚刚创建的用户?

来自分类Dev

为什么Visual Studio代码无法运行我的代码?

来自分类Dev

当我在服务器上运行npm run development时,无法在服务器IP上访问它,为什么?

来自分类Dev

当我在localhost上访问时,为什么我的复选框在chrome上看起来不同?

来自分类Dev

为什么我无法在代码后面找到“栏”?因为我输入了数据模板?我该如何访问?

来自分类Dev

为什么我的Java代码无法编译

来自分类Dev

为什么我的代码无法添加活动?

来自分类Dev

为什么我无法访问某些https网站?

来自分类Dev

为什么Nginx无法在CentOS 7上访问puma套接字?

来自分类Dev

为什么我的fstream访问无法编译?

来自分类Dev

为什么无法访问的代码在C ++中不是错误?

来自分类Dev

为什么我的代码无法访问?

来自分类Dev

为什么我无法访问IPackageFragmentRoot?

来自分类Dev

无法在codeigniter上访问我的网页

来自分类Dev

为什么我的代码无法正常工作?

来自分类Dev

无法在instagram API上访问我自己的关注者

来自分类Dev

为什么我的代码无法正确加载?

来自分类Dev

通过WAN ip甚至在本地网络上访问时,为什么我的NAS会变慢

来自分类Dev

为什么我无法访问表单后面代码中的 xamarin 元素

Related 相关文章

  1. 1

    configatron单身人士?为什么我不能在课堂上访问configatron

  2. 2

    为什么i ++是“无法访问的代码”?

  3. 3

    为什么我的代码无法添加活动?

  4. 4

    为什么我的fstream访问无法编译?

  5. 5

    为什么我无法在我的手机或其他计算机上访问Rails localhost

  6. 6

    为什么无法访问的代码在C ++中不是错误?

  7. 7

    我无法在Xamarin中的代码隐藏上访问Web窗体控件

  8. 8

    为什么内联访问器会破坏我的代码?

  9. 9

    为什么此代码警告在Groovy中无法访问?

  10. 10

    为什么我的代码无法访问?

  11. 11

    为什么我的代码无法访问刚刚创建的用户?

  12. 12

    为什么Visual Studio代码无法运行我的代码?

  13. 13

    当我在服务器上运行npm run development时,无法在服务器IP上访问它,为什么?

  14. 14

    当我在localhost上访问时,为什么我的复选框在chrome上看起来不同?

  15. 15

    为什么我无法在代码后面找到“栏”?因为我输入了数据模板?我该如何访问?

  16. 16

    为什么我的Java代码无法编译

  17. 17

    为什么我的代码无法添加活动?

  18. 18

    为什么我无法访问某些https网站?

  19. 19

    为什么Nginx无法在CentOS 7上访问puma套接字?

  20. 20

    为什么我的fstream访问无法编译?

  21. 21

    为什么无法访问的代码在C ++中不是错误?

  22. 22

    为什么我的代码无法访问?

  23. 23

    为什么我无法访问IPackageFragmentRoot?

  24. 24

    无法在codeigniter上访问我的网页

  25. 25

    为什么我的代码无法正常工作?

  26. 26

    无法在instagram API上访问我自己的关注者

  27. 27

    为什么我的代码无法正确加载?

  28. 28

    通过WAN ip甚至在本地网络上访问时,为什么我的NAS会变慢

  29. 29

    为什么我无法访问表单后面代码中的 xamarin 元素

热门标签

归档