一个端口 (5006) 上有一个 HTTPS 服务器。我想,使其可在35001和(通过添加位置,例如服务于相同的35001太其他的事情/app,/auth,/admin,等)。
服务器是auth-server.org.local. 尝试只添加一个端口:
server {
listen 35001;
location / {
proxy_pass https://auth-server.org.local:5006;
}
}
Run Code Online (Sandbox Code Playgroud)
输出:
$ curl -k -X GET https://auth-server.org.local:5006
<h1>My auth server</h1>
$ curl -k -X GET https://auth-server.org.local:35001
curl: (35) gnutls_handshake() failed: An unexpected TLS packet was received.
Run Code Online (Sandbox Code Playgroud)
为什么 35001 不起作用?我错过了什么?我使用过本指南:https : //www.nginx.com/resources/admin-guide/nginx-https-upstreams/
您的虚拟服务器是 HTTP 服务器,因此它不适用于 https 连接尝试。
为了使其成为 HTTPS,您需要进行以下配置:
server {
listen 35001 ssl;
server_name example.com;
ssl_certificate /path/to/ssl/certificate;
ssl_certificate_key /path/to/ssl/certificate;
location / {
proxy_pass https://auth-server.local:5006;
}
}
Run Code Online (Sandbox Code Playgroud)
或者,您可以设置一个 nginxstream代理,它只是将 TCP 流传递到后端,以便 nginx 不执行 SSL 终止:
stream {
server {
listen 35001;
proxy_pass auth-server.local:5006;
}
}
Run Code Online (Sandbox Code Playgroud)
这必须在http上下文之外。
| 归档时间: |
|
| 查看次数: |
8717 次 |
| 最近记录: |