惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Hackread – Cybersecurity News, Data Breaches, AI and More
U
Unit 42
Vercel News
Vercel News
Martin Fowler
Martin Fowler
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
MongoDB | Blog
MongoDB | Blog
J
Java Code Geeks
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
C
Check Point Blog
N
Netflix TechBlog - Medium
Microsoft Azure Blog
Microsoft Azure Blog
aimingoo的专栏
aimingoo的专栏
博客园_首页
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
IT之家
IT之家
Last Week in AI
Last Week in AI
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
Jina AI
Jina AI
V
Visual Studio Blog
小众软件
小众软件

OpenResty

分享一个在 openresty 搭建 long polling 推送服务的配置文件 云原生网关 Kong 源码分析 v2 有没有用 openresty 开发的? 用 Nginx Openresty 写个网站,写得很痛苦 这个节点这么冷清? [赠票活动 / 北京] BearyChat 邀请你一起参加 OpenResty Con 2015 OpenResty 目前有没有在稳定维护中的 PPA? OpenResty 中有 openssl_sign() 的实现么? 一个可以调试 OpenResty 的 Lua 代码的 IDE
OpenResty 使用 ngx_balancer.set_current_peer() 方法不能设...
Lpl · 2020-10-30 · via OpenResty

文档地址: https://github.com/openresty/lua-resty-core/blob/master/lib/ngx/balancer.md#set_current_peer

syntax: ok, err = balancer.set_current_peer(host, port)

context: balancer_by_lua*

Sets the peer address (host and port) for the current backend query (which may be a retry).

Domain names in host do not make sense. You need to use OpenResty libraries like lua-resty-dns to obtain IP address(es) from all the domain names before entering the balancer_by_lua* handler (for example, you can perform DNS lookups in an earlier phase like access_by_lua* and pass the results to the balancer_by_lua* handler via ngx.ctx.

按照正常 nginx 的逻辑,upstream 中是可以写域名的。此处 OpenResty 文档说不能写域名,但是可以用 DNS 把域名的 IP 解析出来。

解析 IP 的方式在明显不符合需求,假如我有个 test.com 的域名,指向了某个 IP 。这个 IP 是个 nginx,根据 server_name 来区分请求。如果是通过 IP 转发过来的请求,请求头里边是没有 Host 的,所以请求并不能正常转发。

目前不考虑使用 recreate_request 方法来做,有没有什么办法解决这个问题?