node.js - Synology SSL 和 nodejs

标签 node.js express ssl synology

我有一台 synology NAS,我在其中安装了 let's encrypt 证书。从外面我可以浏览到 https://mynas.dyndns.info我会收到一个安全页面。所以这我工作正常!

现在我正尝试在端口 3000 上运行一个 nodejs 服务器。我怎样才能使这个连接安全?我不知道从哪里开始。任何提示教程,示例?

提前致谢

彼得

最佳答案

在这种情况下,您或许可以制作一个反向代理。

对于 nginx,我将此基本配置用于我的 Node 应用程序:

server {

    listen       80;
    server_name  localhost;

    location /actions {
        rewrite ^/actions$ / break;
        rewrite ^/actions/(.*) /$1 break;
        proxy_pass http://127.0.0.1:5000;
    }
    location / {
        proxy_pass http://127.0.0.1:8081;
    }
}

对于作为 Web 服务器的 apache

  1. Create a folder in www or public_html, let's say node
  2. Inside node I make a .htaccess file and
  3. add the following lines,

    RewriteEngine On
    RewriteRule ^$ http://127.0.0.1:8080/ [P,L] #which is your node server ip:port
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ http://127.0.0.1:8080/$1 [P,L] #same ip:port
    

关于node.js - Synology SSL 和 nodejs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53547464/

相关文章:

node.js - 具有延迟约束的 Postgres Sequelize 事务不起作用

node.js - Node js 的架构和数据迁移

node.js - iisnode-IIS7.5 : 405 Method not allowed when performing PUT request

javascript - rethinkdb 在 express 中更改 feed,其中 socket.io 显示 [object object]

node.js - 如何在没有 `gcloud app deploy` 的情况下在 GCP 上部署 Node.js Express 服务器?

Django:检查模板的连接是否安全?

node.js - MongoDB 按相关性排序

Node.js HLTV 评分机器人无法正常工作

android - 覆盖 Android 中的 SSL 信任管理器

ssl - 如何引用名称中带有哈希后缀的证书管理器生成的 secret ?