Comments (5)
这一块源码我还没有接触,本周我看一下upstream这里在给你回复吧
from nginx-1.16.0.
感谢大拿,感谢大拿
from nginx-1.16.0.
nginx upstream的名字长度限制是多少?
1 . ngx_init_cycle() 默认申请16k内存
ngx_conf_parse() 解析配置文件
ngx_conf_read_token() 检查语法
word = ngx_array_push(cf->args)利用动态数组保存解析配置值
这里配置值的解析空间都是从内存池解析的,最大不超过16k
2. ngx_http_upstream() upsteam指令的回调函数
value = cf->args->elts;
u.host = value[1]; //upstream backend { }中的backend
这里直接可以使用gdb调试,我的调试结果
(gdb) p *cf->args
$16 = {elts = 0x73b110, nelts = 2, size = 16, nalloc = 10, pool = 0x739100}
(gdb) p ((ngx_str_t *) cf->args->elts)[0]
$19 = {len = 8, data = 0x74fb4f "upstream"}
(gdb) p ((ngx_str_t *) cf->args->elts)[1]
$20 = {len = 7, data = 0x74fb58 "backend"}
3. 如何调试nginx?
a) nginx.conf配置文件
daemon off;
master_process off;
upstream backend{
server localhost:8001;
}
location / {
root html;
index index.html index.htm;
proxy_pass http://backend;
}
b) 编译nginx
-O0进制编译器优化,-g参数调试使用
./configure --prefix=/usr/local/nginx --with-cc-opt="-O0" --with-debug && make -j8 && make install
c)gdb参数设置
gdb --args ./objs/nginx -c /usr/local/nginx/conf/nginx.conf
set follow-fork-mode child
b ngx_http_upstream.c:5696
如果有什么问题,随时交流
from nginx-1.16.0.
非常感谢你,不光解答了问题,还给了测试方式。谢谢
from nginx-1.16.0.
不客气,有什么问题随时交流
from nginx-1.16.0.
Related Issues (20)
- nginx的ngx_http_random_index_module(随机选择目录的index页面)?
- cpu周期性异常100%?
- 共享内存意外退出导致程序无法正常启动?
- 采坑-删除正在运行的程序?
- 如何确认某个进程是某个cpu上运行?
- 这种IO毛刺如何定位呢?
- protobuf 安装及其使用记录
- 用户反馈某个文件一直失败?
- 文件写不进去磁盘?导致大量回源失败?
- 访问不通tcp三次握手分析
- cpu 异常高负载?
- https 怎么才可以走ip + host直通访问?
- fork: Cannot allocate memory问题? HOT 1
- SRE 实践?
- curl 支持发起http2请求?
- 运维同学反馈机器cpu使用高?(机器负载问题如何查询)
- Nginx 4层 怎么获取源ip
- 有人反馈 客户端连接nginx有时候会连接超时?
- tcp的连接四元组(特殊情况)?
- 遇到errno 27?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nginx-1.16.0.