GUI / nginx-upstream-dynamic-servers

An nginx module to resolve domain names inside upstreams and keep them up to date.
MIT License
311 stars 74 forks source link

Build failures w/ Nginx 1.11.2 #20

Closed peterhanneman closed 8 years ago

peterhanneman commented 8 years ago

Been using this module on a production reverse proxy for 6+ months now without issue. Unfortunately now I can't get this module to compile against the latest Nginx 1.11.2. I know for a fact is worked with 1.11.1 w/ an unknown older commit hash but I sadly deleted the old build directory prematurely.

Trying to compile against tag v0.3.0 & v0.4.0 both yield:

/home/ubuntu/src/build/nginx-upstream-dynamic-servers/ngx_http_upstream_dynamic_servers.c: In function ‘ngx_http_upstream_dynamic_server_resolve_handler’:
/home/ubuntu/src/build/nginx-upstream-dynamic-servers/ngx_http_upstream_dynamic_servers.c:431:16: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
     ctx->addrs = u.addrs;
/home/ubuntu/src/build/nginx-upstream-dynamic-servers/ngx_http_upstream_dynamic_servers.c:444:14: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
     new_addr = &ctx->addrs[i];

Trying to compile against the latest master yields:

objs/addon/nginx-upstream-dynamic-servers/ngx_http_upstream_dynamic_servers.o (symbol from plugin): In function `ngx_http_upstream_dynamic_servers_module':
(.text+0x0): multiple definition of `ngx_http_upstream_dynamic_servers_module'
objs/addon/nginx-upstream-dynamic-servers/ngx_http_upstream_dynamic_servers.o (symbol from plugin):(.text+0x0): first defined here
In function ‘__recv_alias’,
    inlined from ‘ngx_http_ssl_handshake’ at src/http/ngx_http_request.c:651:7:
/usr/include/x86_64-linux-gnu/bits/socket2.h:39:9: warning: call to ‘__recv_chk_warn’ declared with attribute warning: recv called with bigger length than size of destination buffer
  return __recv_chk (__fd, __buf, __n, __bos0 (__buf), __flags);

Compiling against the latest master I noticed that "cc -o objs/nginx ..." command includes two references to "objs/addon/nginx-upstream-dynamic-servers/ngx_http_upstream_dynamic_servers.o" which may be the only issue?

Thanks in advance for taking the time to look at this. Let me know if you need any other information to help isolate the issue.

wandenberg commented 8 years ago

@timelessvirtues the tags v0.3.0 & v0.4.0 really don't work with later versions of nginx but the master commit does. Try to do a clean setup, probably your local repository is with some wrong reference. I just did this here and worked fine.

$ mkdir /tmp/build
$ cd /tmp/build/
$ wget -c -N http://nginx.org/download/nginx-1.11.2.tar.gz; tar xzf nginx-1.11.2.tar.gz;
$ git clone git@github.com:GUI/nginx-upstream-dynamic-servers.git
$ cd nginx-1.11.2/
$ ./configure --add-module=../nginx-upstream-dynamic-servers
$ make 
$ ./objs/nginx -V
nginx version: nginx/1.11.2
built by gcc 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2.1) 
configure arguments: --add-module=../nginx-upstream-dynamic-servers
peterhanneman commented 8 years ago

For some reason your module has an issue compiling w/ the NAXSI web application firewall module.

Moving the NAXSI's --add-module to before your module's fixed the issue. Quite bizarre behavior but thanks for your time.

Works:

./configure \
--prefix=/opt/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--user=www-data \
--group=www-data \
--without-select_module \
--without-poll_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_stub_status_module \
--without-http_charset_module \
--without-http_ssi_module \
--without-http_userid_module \
--without-http_autoindex_module \
--without-http_geo_module \
--without-http_split_clients_module \
--without-http_referer_module \
--without-http_fastcgi_module \
--without-http_uwsgi_module \
--without-http_scgi_module \
--without-http_memcached_module \
--without-http_limit_conn_module \
--without-http_limit_req_module \
--without-http_empty_gif_module \
--without-http_browser_module \
--without-http_upstream_hash_module \
--without-http_upstream_ip_hash_module \
--without-http_upstream_least_conn_module \
--without-http_upstream_zone_module \
--without-http-cache \
--add-module=../naxsi/naxsi_src \
--add-module=../nginx-upstream-dynamic-servers \
--with-cc-opt="-Ofast -march=native -flto -fwhole-program -I ../build/staticlibssl/include" \
--with-ld-opt="-L ../build/staticlibssl/lib -Wl,-rpath -lssl -lcrypto -ldl -lz" \
--with-pcre=../build/pcre-8.39/ \
--with-pcre-jit \
--with-libatomic

Does not work:

./configure \
--prefix=/opt/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--user=www-data \
--group=www-data \
--without-select_module \
--without-poll_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_stub_status_module \
--without-http_charset_module \
--without-http_ssi_module \
--without-http_userid_module \
--without-http_autoindex_module \
--without-http_geo_module \
--without-http_split_clients_module \
--without-http_referer_module \
--without-http_fastcgi_module \
--without-http_uwsgi_module \
--without-http_scgi_module \
--without-http_memcached_module \
--without-http_limit_conn_module \
--without-http_limit_req_module \
--without-http_empty_gif_module \
--without-http_browser_module \
--without-http_upstream_hash_module \
--without-http_upstream_ip_hash_module \
--without-http_upstream_least_conn_module \
--without-http_upstream_zone_module \
--without-http-cache \
--add-module=../nginx-upstream-dynamic-servers \
--add-module=../naxsi/naxsi_src \
--with-cc-opt="-Ofast -march=native -flto -fwhole-program -I ../build/staticlibssl/include" \
--with-ld-opt="-L ../build/staticlibssl/lib -Wl,-rpath -lssl -lcrypto -ldl -lz" \
--with-pcre=../build/pcre-8.39/ \
--with-pcre-jit \
--with-libatomic