gpt4 book ai didi

node.js - NGINX 不路由 https 请求

转载 作者:太空宇宙 更新时间:2023-11-03 14:46:36 26 4
gpt4 key购买 nike

我有一个带有 nginx 路由到 Node Web 服务器的反向代理

我在 Web 服务器上设置(我认为)SSL,但看起来当我的浏览器尝试解析 https 请求时,连接从未启动。

我想问几个问题

  1. 我在哪里设置 SSL?在第一次命中请求的反向代理上?还是认证发生的 Node 服务器?

  2. 我的配置有什么问题(如果这是问题所在

https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-on-ubuntu-14-04

这是我用的教程

包含代码(对不起,我完全忘了包含)

server {
listen 443 ssl;

server_name domain www.domain.com;

ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-$
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:50m;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security max-age=15768000;


location / {
proxy_pass http://app_server_ip:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

server {
listen 80;
server_name domain.com www.domain.com;
return 301 https://$host$request_uri;
}

最佳答案

1.关于反向代理

2.你应该像下面这样配置nginx文件(使用upstream参数):

        upstream api-app {
least_conn;
server 127.0.0.1:3000 weight=1 max_fails=0;
}
server {
listen 80;
listen 443 ssl;
server_name api.domain.net;
ssl_certificate /etc/letsencrypt/live/api.domain.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.domain.net/privkey.pem;
client_max_body_size 2000M;
large_client_header_buffers 32 128k;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://api-app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

关于node.js - NGINX 不路由 https 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38465117/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com