Coder Social home page Coder Social logo

Comments (5)

vaynedu avatar vaynedu commented on June 11, 2024

这一块源码我还没有接触,本周我看一下upstream这里在给你回复吧

from nginx-1.16.0.

saga1015 avatar saga1015 commented on June 11, 2024

感谢大拿,感谢大拿

from nginx-1.16.0.

vaynedu avatar vaynedu commented on June 11, 2024

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.

saga1015 avatar saga1015 commented on June 11, 2024

非常感谢你,不光解答了问题,还给了测试方式。谢谢

from nginx-1.16.0.

vaynedu avatar vaynedu commented on June 11, 2024

不客气,有什么问题随时交流

from nginx-1.16.0.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.