Giter Site home page Giter Site logo

ygy203 / nginx-nacos-upstream Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nacos-group/nginx-nacos-upstream

0.0 0.0 0.0 1.25 MB

nginx dynamic upstream module for nacos. subcribe nacos and update address automaticly without reloading config

License: BSD 2-Clause "Simplified" License

Shell 0.01% C++ 0.01% Perl 0.12% C 96.80% HTML 0.02% CMake 0.13% XS 0.46% Vim Script 2.44%

nginx-nacos-upstream's Introduction

NGNIX NACOS 模块

nginx 通过订阅 nacos ip 端口, 进行反向代理。不用 reload 重启进程

配置示例

基于 NGINX 1.20.2 和 NACOS 2.10 版本开发。

nacos {
    server_list localhost:8848; # nacos 服务器列表,空格隔开
    udp_port 19999; #udp 端口号
    udp_ip 127.0.0.1; #udp ip 地址。
    udp_bind 0.0.0.0:19999; # 绑定udp 地址
    error_log logs/nacos.log info;
    default_group DEFAULT_GROUP; # 默认的nacos group name
    cache_dir cmake-build-debug/nacos/;
}
http {
    upstream s {
        use_nacos_address data_id=cc group=aaa; # 使用nacos ip
    }
    server {
        # ... other config
        location ^~ / {
            proxy_pass http://s;
        }
    }
}

编译

./configure --add-module=modules/auxiliary --add-module=modules/nacos && make

原理

  • 新增加一个 auxiliary 模块, 启动一个单独辅助进程,用于订阅和接受 nacos 的 udp 消息推送,不影响 worker 进程的工作。
  • 收到消息推送后更新到共享内存,便于 worker 进程可以拿到最新的推送。 推送的数据也会缓存到磁盘,下次启动时候首先从磁盘读取。

nginx-nacos-upstream's People

Contributors

zhwaaaaaa avatar

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.