Code Monkey home page Code Monkey logo

ngx_upstream_jdomain's Introduction

ngx_upstream_jdomain

An asynchronous domain name resolve module for nginx upstream

Installation:

./configure --add-module=/path/to/this/directory
make
make install

Usage:

upstream backend {                                                                              
	jdomain www.baidu.com; #port=80                                                             
	#jdomain www.baidu.com port=8080; #port=8080
}

resolver 8.8.8.8; #Your Local DNS Server

Jdomain:

* Syntax: jdomain <domain-name> [port=80] [max_ips=20] [interval=1] [retry_off]
* Context:    upstream                                                                          
* port:       Backend's listening port.                                                         
* max_ips:    IP buffer size.
* interval:   How many seconds to resolve domain name.
* retry_off:  Do not retry if one IP fails. 

See https://www.nginx.com/resources/wiki/modules/domain_resolve/ for details.

Author

wdaike [email protected], Baidu Inc.

Copyright & License

This module is licenced under the BSD License. Copyright (C) 2014-2014, by wdaike [email protected], Baidu Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ngx_upstream_jdomain's People

Contributors

itpp16 avatar rs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx_upstream_jdomain's Issues

License?

I didn't see license information anywhere in this project. Any chance you could clear that up? Thanks!

error compiling with nginx 1.12

Hello, when trying to compile in a ubuntu:xenail machine, i got an error saying

cc -c -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -g -O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2  -I src/core -I src/event -I src/event/modules -I src/os/unix -I /usr/include/libxml2 -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/mail -I src/stream \
	-o objs/addon/ngx_upstream_jdomain/ngx_http_upstream_jdomain.o \
	/opt/jdomain/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c
In file included from src/core/ngx_core.h:58:0,
                 from /opt/jdomain/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c:7:
/opt/jdomain/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c: In function ‘ngx_http_upstream_set_jdomain_peer_session’:
/opt/jdomain/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c:521:42: error: dereferencing pointer to incomplete type ‘SSL_SESSION {aka struct ssl_session_st}’
    ssl_session, ssl_session ? ssl_session->references : 0);
                                          ^
src/core/ngx_log.h:93:48: note: in definition of macro ‘ngx_log_debug’
         ngx_log_error_core(NGX_LOG_DEBUG, log, __VA_ARGS__)
                                                ^
/opt/jdomain/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c:519:2: note: in expansion of macro ‘ngx_log_debug2’
  ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
  ^
objs/Makefile:1397: recipe for target 'objs/addon/ngx_upstream_jdomain/ngx_http_upstream_jdomain.o' failed
make[3]: *** [objs/addon/ngx_upstream_jdomain/ngx_http_upstream_jdomain.o] Error 1
make[3]: Leaving directory '/opt/rebuildnginx/nginx-1.12.1/debian/build-full'
Makefile:8: recipe for target 'build' failed
make[2]: *** [build] Error 2
make[2]: Leaving directory '/opt/rebuildnginx/nginx-1.12.1/debian/build-full'
debian/rules:163: recipe for target 'build.arch.full' failed
make[1]: *** [build.arch.full] Error 2
make[1]: Leaving directory '/opt/rebuildnginx/nginx-1.12.1'
debian/rules:141: recipe for target 'build' failed
make: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2

is there anywork around for this, os is maybe a versions incopatibility problem? thank you

Use separate resolvers

Instead of using system's /etc/resolv.conf, can we use different resolvers? nginx now allows to define own resolvers http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver but I am not sure if this module can use that.
This will allow us to query service discovery platform, e.g.: https://www.consul.io/docs/agent/dns.html
upstream servers can register against "consul", and "consul" can take care of health check.

Can you also add the dns SRV record support? We can then set the weight, port, etc directly in the DNS.

ngx_upstream_jdomain support openssl1.1.1c?

ngx_upstream_jdomain support openssl1.1.1c?
versions:
・nginx 1.16.0
・openssl 1.1.1c
When running the make command, an error appears in ngx_http_upstream_jdomain.c :

usr/local/src/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c: In function ‘ngx_http_upstream_set_jdomain_peer_session’:
/usr/local/src/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c:521:42: error: dereferencing pointer to incomplete type
    ssl_session, ssl_session ? ssl_session->references : 0);
                                          ^
src/core/ngx_log.h:93:48: note: in definition of macro ‘ngx_log_debug’
         ngx_log_error_core(NGX_LOG_DEBUG, log, __VA_ARGS__)
                                                ^
/usr/local/src/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c:519:2: note: in expansion of macro ‘ngx_log_debug2’
  ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
  ^
/usr/local/src/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c: In function ‘ngx_http_upstream_save_jdomain_peer_session’:
/usr/local/src/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c:543:51: error: dereferencing pointer to incomplete type
    "save session: %p:%d", ssl_session, ssl_session->references);
                                                   ^
src/core/ngx_log.h:93:48: note: in definition of macro ‘ngx_log_debug’
         ngx_log_error_core(NGX_LOG_DEBUG, log, __VA_ARGS__)
                                                ^
/usr/local/src/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c:542:2: note: in expansion of macro ‘ngx_log_debug2’
  ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
  ^
/usr/local/src/ngx_upstream_jdomain/ngx_http_upstream_jdomain.c:555:37: error: dereferencing pointer to incomplete type
     old_ssl_session, old_ssl_session->references);
                                     ^
src/core/ngx_log.h:93:48: note: in definition of macro ‘ngx_log_debug’
         ngx_log_error_core(NGX_LOG_DEBUG, log, __VA_ARGS__)

Problems on latest nginx / non port 80?

Is anyone using this successfully? I'm trying to use this to refresh DNS entries on a containerized structure, however I keep getting errors like:

nginxweb_1 | 2016/01/21 19:28:18 [emerg] 1#0: invalid parameter "9000" in /etc/nginx/conf.d/upstream.conf:2
nginxweb_1 | nginx: [emerg] invalid parameter "9000" in /etc/nginx/conf.d/upstream.conf:2

Here is my upstream.conf

upstream php-upstream {
    jdomain php5 9000;
}

If I remove the 9000 it "works", but doesnt work for my needs as a backend in proxypass as it defaults to port 80 and I get errors saying the backend isnt available at IP:80...

是否支持hash key

我的应用场景是在kubernetes集群中使用headless service,myproxy-service能解析出多个ip,并且ip列表可能变化。我希望根据url中的sn参数进行hash,选定server。不知道ngx_upstream_jdomain是否支持这种场景。类似如下配置:

    upstream myproxy {
        hash $arg_sn consistent;

        jdomain myproxy-service 8080;
    }

此外具体的设计有没有相应文档,实现是把解析出来的ip列表以nginx server的形式提供给upstream吗?

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.