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

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
爱范儿
爱范儿
The Cloudflare Blog
Y
Y Combinator Blog
B
Blog RSS Feed
Stack Overflow Blog
Stack Overflow Blog
博客园 - 叶小钗
G
Google Developers Blog
J
Java Code Geeks
P
Proofpoint News Feed
美团技术团队
Engineering at Meta
Engineering at Meta
腾讯CDC
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
有赞技术团队
有赞技术团队
L
LangChain Blog
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】

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 方法来做,有没有什么办法解决这个问题?