【问题标题】:What is the difference in configuring SSL on Sails, between set it on Nginx?在 Sails 上配置 SSL 和在 Nginx 上设置 SSL 有什么区别?
【发布时间】:2015-07-14 16:35:50
【问题描述】:

我目前使用这个 Nginx 配置:

server {
    listen 80;
    return 301 https://$host$request_uri;
}

server {

    listen 443;
    server_name www.domain.com;

    ssl_certificate           /etc/nginx/cert.crt;
    ssl_certificate_key       /etc/nginx/cert.key;

    ssl on;
    ssl_session_cache  builtin:1000  shared:SSL:10m;
    ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
    ssl_prefer_server_ciphers on;

    access_log            /var/log/nginx/domain.access.log;

    location / {

      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      # Fix the “It appears that your reverse proxy set up is broken" error.
      proxy_pass          http://localhost:8086;
      proxy_read_timeout  90;

      proxy_redirect      http://localhost:8086 https://www.domain.com;
    }
}

有了这个我没有问题,但我刚刚看到this问题包含:

express : {
    serverOptions : {
        key: fs.readFileSync('ssl/server.key'),
        cert: fs.readFileSync('ssl/server.crt')
    }
}

使用 https 的最佳方式是什么?我托管在 Google Cloud 中,并且在不同的端口中有一些页面使用 Nginx proxy_pass

【问题讨论】:

    标签: ssl nginx https sails.js


    【解决方案1】:

    我不知道您是否正在考虑完全删除 Nginx 并直接为您的节点应用程序提供服务。但是如果你不打算完全删除它,我宁愿保留 Nginx 中的配置,以分离应用程序和 Web 服务器的职责。

    使用 Nginx,您还可以准备添加负载平衡、反向代理缓存、更有效地服务资产等功能......

    【讨论】:

    • 所以。我现在不需要在 Sails 中配置任何东西吗?
    • 如果 Nginx 处理 SSL,那么后面的 node.js 应用程序就不必知道它的任何信息。客户端的浏览器将通过 https 与 Nginx 通信,而 Nginx 将通过 http 与 node.js 应用程序通信。您只需要知道 Nginx 和应用程序之间的通信不会加密。
    猜你喜欢
    • 1970-01-01
    • 2014-12-17
    • 1970-01-01
    • 2018-05-08
    • 2018-09-23
    • 2016-10-18
    • 1970-01-01
    • 2011-03-05
    相关资源
    最近更新 更多