【发布时间】:2020-05-03 12:40:00
【问题描述】:
我想设置一个 nginx 实例,它将从 /api 开始的 HTTP 请求代理到 HTTPS 服务器,但 /api URL 段应该省略。 例如,实例应该监听 localhost:9817。如果它收到对http://localhost:9817/api/auth 的请求,它应该将其代理为https://api.com:8443/auth。
这是我的 nginx 配置:
events {
worker_connections 1024;
}
http {
server {
listen 9817;
server_name localhost;
location /api {
rewrite ^/api(/.*) $1 break;
proxy_pass https://api.com:8443;
proxy_set_header Host $host;
proxy_http_version 1.1;
}
location / {
root "D:/Project/dist";
try_files $uri $uri/ /index.html;
}
}
}
但是,我在 error.log 中收到以下错误:
2020/01/16 17:54:22 [error] 420512#426216: *31 peer closed connection in SSL handshake (10054: An existing connection was forcibly closed by the remote host) while SSL handshaking to upstream, client: 127.0.0.1, server: localhost, request: "POST /api/auth HTTP/1.1", upstream: "https://16.53.35.38:8443/auth", host: "localhost:9817", referrer: "http://localhost:9817/"
这个错误的原因是什么?如何修复它或根据需要设置代理?
【问题讨论】:
-
您好,我遇到了同样的错误。谷歌不知道这个错误。你修复了这个错误吗?
-
您好!不,我没有。我的项目不再需要这种代理,因此问题变得无关紧要。
标签: ssl nginx https proxy reverse-proxy