ZigzagAK / ngx_dynamic_upstream

Dynamic upstream for nginx
Other
34 stars 11 forks source link

backend.peers #4

Closed hxhui94 closed 5 years ago

hxhui94 commented 5 years ago

why this file not update when i add a stream or remove a stream

ZigzagAK commented 5 years ago

Please, send me your configuration in archive. You must add dynamic_state_file directive to upstream.

ZigzagAK commented 5 years ago

Yes, exists trouble when you add bad server name. Resolving process breaks on this situation. I will resolve this problem in short time.

ZigzagAK commented 5 years ago

@hxhui94 I have fix described trouble.

ZigzagAK commented 5 years ago

stream or remove a stream Yes, I forgot add directive for stream module. Fixed. Thanks.

hxhui94 commented 5 years ago

thanks for reply. what is persistanted in backends.peer.does it means the upstream server?

is it right such that? [root@server01 nginx]# curl "http://127.0.0.1:6000/dynamic?upstream=backends" server 0.0.0.0:1 addr=0.0.0.0:1 down; server 192.168.81.11:80 addr=192.168.81.11:80; [root@server01 nginx]# more conf/backend.peers server 0.0.0.0:1 down; [root@server01 nginx]# [root@server01 nginx]# [root@server01 nginx]# curl "http://127.0.0.1:6000/dynamic?upstream=backends&add=&server=192.168.81.11:30400" server 0.0.0.0:1 addr=0.0.0.0:1 down; server 192.168.81.11:80 addr=192.168.81.11:80; server 192.168.81.11:30400 addr=192.168.81.11:30400; [root@server01 nginx]# [root@server01 nginx]# more conf/backend.peers server 0.0.0.0:1 down; [root@server01 nginx]#

ZigzagAK commented 5 years ago

Hi, it is not correct. I will check in nearest time how does it happens. Server 0.0.0.0 must be present in reply only for empty upstream (nginx cannot contents absolutely empty upstream and we must add fake server in it). Please, attach conf file and error.log to this issue.

hxhui94 commented 5 years ago

nginx.conf events { worker_connections 1024; } http { upstream backends { dynamic_state_file backend.peers; zone zone_for_backends 1m; server 192.168.81.11:80; }

server {
    listen 6000;
    location /dynamic {
        allow 127.0.0.1;
        deny all;
        dynamic_upstream;
    }
    location / {
        proxy_pass http://backends;
    }
}

}

error.log [root@server01 logs]# more error.log 2019/01/10 00:39:55 [warn] 1456#0: can't open file: /usr/local/nginx/conf/backend.peers 2019/01/10 00:39:59 [alert] 1465#0: detected a LuaJIT version which is not OpenResty's; many optimizations will be disabled and performance will be compromised (see ht tps://github.com/openresty/luajit2 for OpenResty's LuaJIT or, even better, consider using the OpenResty releases from https://openresty.org/en/download.html)

ZigzagAK commented 5 years ago

error.log is clear. Please, set error_log error.log info level and reproduce case. On info level in error.log you may see all add/remove operations.

ZigzagAK commented 5 years ago

@hxhui94 You MUST not use explicit declaration servers in upstream section. If you want to add static servers, you MUST create backend.peers file manually and add these servers into it. I will add this comment in directive description.

hxhui94 commented 5 years ago

thank you so much