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

Nginx SSL pass-through based on uri path

· 52CE 我爱测

I'd like to know if it is possible to configure Nginx to dynamically send request (without SSL termination) to given microservice? In my architecture I have two microservices. Lets assume that they are localhost:5000 and localhos…

问题原文

原帖链接 · Kamil Czyznielewski · CC BY-SA 3.0

I'd like to know if it is possible to configure Nginx to dynamically send request (without SSL termination) to given microservice?

In my architecture I have two microservices. Lets assume that they are localhost:5000 and localhost:5100. I'd like to send all request (that come to Nginx proxy) that start with /api to localhost:5000 and /services to localhost:5100. I have configured SSL on both microservices so I do not need SSL termination on Nginx.

Is this possible?

已采纳解答

原帖链接 · kasperd · CC BY-SA 3.0

What you are asking to do is impossible. This is not a limitation of Nginx, rather it is a consequence of how SSL works.

Passing a connection through a load balancer without terminating SSL requires the load balancer to choose a backend before it will be able to forward the ServerHello message from the server back to the client. However at that early stage the client has not yet send the URI, so it cannot be used in the choice of backend.

The alternatives you have are as follows:

  • Terminate SSL on the load balancer.
  • Host the services on two different IP addresses.
  • Host the services on two different port numbers.
  • Host the services on two different domain names.

If you have a hard requirement for the URLs to use a specific domain and no port number in the URLs, most of those options will be eliminated and terminating SSL on the load balancer will be your only option.

The reason I distinguish between using two different IP address and using two different domain names is that two domain names pointing to the same IP address is a possibility, but only as long as the clients support SNI. (In that scenario you can only make one of the domains work for clients without SNI).

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

资料来源与适用范围

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

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

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