配置SingBox节点的步骤如下

  1. 安装Node.js:

    在你的操作系统上安装Node.js,如果不确定,可以通过官网或包管理器安装。

  2. 生成自签名证书:

    • 打开终端,进入需要存放证书的目录。
    • 安装必要的工具:sudo apt-get install openssl(在Ubuntu上)。
    • 生成私钥:openssl genrsa -des 3:2048 > server.key。
    • 生成证书签名请求:openssl req -new -key server.key -out server.csr -days 365。
    • 生成证书:openssl x509 -req -key server.key -out server.crt -days 365 -signkey server.key。
  3. 创建Node.js项目:

    • 在项目目录创建文件,server.js:

      const express = require('express');
      const https = require('https');
      const fs = require('fs');
      const path = require('path');
      const app = express();
      const server = https.createServer({
        key: fs.readFileSync('server.key'),
        cert: fs.readFileSync('server.crt')
      }, () => {
        console.log('HTTPS服务器已启动在localhost:8443');
      });
      app.use(express.static('public'));
      app.get('/', (req, res) => {
        res.sendFile('public/index.html');
      });
      app.post('/api', (req, res) => {
        console.log('收到POST请求:', req.body);
        res.send('接收成功!');
      });
      server.listen(8443, () => {
        console.log('HTTPS服务器正在运行在localhost:8443');
      });
  4. 运行服务器:

    • 在终端中运行 node server.js,服务器将在8443端口使用HTTPS监听。
  5. 访问服务器:

    • 打开浏览器,访问 https://localhost:8443。
    • 如果浏览器提示证书错误,可能需要在server.crt中添加证书颁发者,或者在本地hosts文件中配置。
  6. 测试功能:

    • 测试GET请求:访问 https://localhost:8443,查看index.html页面。
    • 测试POST请求:使用工具如Postman发送POST请求到/api,检查服务器是否接收数据。
  7. 验证证书配置:

    在浏览器中检查证书详情,确保私钥和证书对应正确。

通过以上步骤,你已经配置好了一个基本的SingBox节点,能够在HTTPS下接收HTTP请求。

配置SingBox节点的步骤如下

扫码添加极光VPN官方微信

扫码添加极光VPN官方微信

400-683-9275
扫码添加极光VPN官方微信

扫码添加极光VPN官方微信

网站地图