我有一台 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
- Create a folder in www or public_html, let's say
node
- Inside node I make a
.htaccess
file andadd 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/