大网数据广告活动
服务器运维问答

nginx: Upstream SSL, how is it encrypting on the backend?

· 52CE 我爱测

I've been researching this question, and cannot find a definitive answer. I am really trying to get a grasp on this before deploying to production, and most nginx resources I've found aren't very clear at explaining what's happen…

问题原文

原帖链接 · Clark Brent · CC BY-SA 4.0

I've been researching this question, and cannot find a definitive answer. I am really trying to get a grasp on this before deploying to production, and most nginx resources I've found aren't very clear at explaining what's happening behind nginx when serving traffic to the proxies.

Basically, I am trying to encrypt requests both to the client from nginx, and from nginx to the proxied servers behind it. After reading, and following examples, I've come up with a config that seems to be working. At least working in that the client is receiving requests over SSL.

My question is whether my original concern of encrypting traffic both ways is actually accomplished with the following config or if the connections from nginx to the proxied servers are still over http rather than https:

upstream app1 {
        server app1:3000;
}

upstream app2 {
        server app2:5000;
}

server {
       listen         80 default_server;
       listen    [::]:80 default_server;
       server_name    localhost;
       return         301 https://$server_name$request_uri;
}

server {
        listen            443 ssl http2;
        listen            [::]:443 ssl http2;
        server_name       localhost;

        ssl_certificate /etc/ssl/localhost-cert.crt;
        ssl_certificate_key /etc/ssl/localhost-privkey.key;

        ssl_protocols TLSv1.2;
        ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
        ssl_prefer_server_ciphers on;

        location / {
          proxy_pass http://app1;
        }

        location /api {
          proxy_pass http://app2;
        }
}

If the connections from nginx to the proxied servers are still in plaintext, how would I go about encrypting that data as well from nginx rather than from the app servers themselves?

已采纳解答

原帖链接 · Quantim · CC BY-SA 4.0

your config use plain HTTP to contact backend servers, for securing this path you need to use https on this part too. There is perfect article how to achieve this in official doc

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-02-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。