GithubHelp home page GithubHelp logo

openresty's Introduction

Name

OpenResty - Turning Nginx into a Full-Fledged Scriptable Web Platform

Table of Contents

Description

OpenResty is a full-fledged web application server by bundling the standard nginx core, lots of 3rd-party nginx modules, as well as most of their external dependencies.

This bundle is maintained by Yichun Zhang (agentzh).

Because most of the nginx modules are developed by the bundle maintainers, it can ensure that all these modules are played well together.

The bundled software components are copyrighted by the respective copyright holders.

The homepage for this project is on openresty.org.

For Users

Visit the download page on the openresty.org web site to download the latest bundle tarball, and follow the installation instructions in the installation page.

For Bundle Maintainers

The bundle's source is at the following git repository:

https://github.com/openresty/openresty

To reproduce the bundle tarball, just do

make

at the top of the bundle source tree.

Please note that you may need to install some extra dependencies, like perl, dos2unix, and mercurial. On Fedora 22, for example, installing the dependencies is as simple as running the following commands:

sudo dnf install perl dos2unix mercurial

Back to TOC

Additional Features

In additional to the standard nginx core features, this bundle also supports the following:

Back to TOC

resolv.conf parsing

syntax: resolver address ... [valid=time] [ipv6=on|off] [local=on|off|path]

default: -

context: http, stream, server, location

Similar to the resolver directive in standard nginx core with additional support for parsing additional resolvers from the resolv.conf file format.

When local=on, the standard path of /etc/resolv.conf will be used. You may also specify arbitrary path to be used for parsing, for example: local=/tmp/test.conf.

When local=off, parsing will be disabled (this is the default).

This feature is not available on Windows platforms.

Back to TOC

Mailing List

You're very welcome to join the English OpenResty mailing list hosted on Google Groups:

https://groups.google.com/group/openresty-en

The Chinese mailing list is here:

https://groups.google.com/group/openresty

Back to TOC

Report Bugs

You're very welcome to report issues on GitHub:

https://github.com/openresty/openresty/issues

Back to TOC

Copyright & License

The bundle itself is licensed under the 2-clause BSD license.

Copyright (c) 2011-2019, Yichun "agentzh" Zhang (章亦春) [email protected], OpenResty Inc.

This module is licensed under the terms of the BSD license.

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.

Back to TOC

openresty's People

Contributors

agentzh avatar catatsuy avatar catbro666 avatar chewi avatar davidgaleano avatar dndx avatar fesily avatar hawkxiang avatar jbampton avatar jsoref avatar krishvoor avatar liseen avatar meathill avatar membphis avatar namrata-ibm avatar needcaffeine avatar nightsailer avatar rocfang avatar ruoyidero avatar smallfish avatar spacewander avatar swananan avatar thibaultcha avatar tjwudi avatar velemas avatar xiaocang avatar xvaara avatar yaoweibin avatar zhuizhuhaomeng avatar zloidemon 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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openresty's Issues

I am an idiot

Got my modules mixed up. The one I wanted is in core and just disabled; I thought it was not included as standard. My bad.

drizzle connection

I posted this on the ngx_drizzle issue also. I am using openresty with the drizzle module. I have everything running fine on my mac. I installed the same thing on a Ubuntu EC2 instance, and everything is working except the database connection to mysql through drizzle. Any subrequest, or direct request that goes through the /mysql location returns a 200 with 0 data. If I go to /mysql_pool_status, the same thing. 200 with 0 data. I get no error message in error.log.

The /mysql location is:location

/mysql {
rds_json on;
drizzle_query $arg_sql;
default_type application/json;
drizzle_connect_timeout 500ms;

drizzle_send_query_timeout 2s;

drizzle_pass backend;
}

upstream backend {
drizzle_server 127.0.0.1:3306 dbname=identity user=root protocol=mysql;
}

I access the /mysql location using ngx.location.capture. In this case, it never returns, but looks like it exits. Again with a 200 and 0 data.

I can connect to the database through port 3306 in other ways.

My problem is that I can't trouble shoot this because there are no errors in error.log. How should I proceed.

Incidentally, it's running on Hardy and openresty 1.0.4, drizzle 7-2011.08.24, and mysql 5.0.

fail to make when use 'make -j'

i built openresty ngx_openresty-1.2.4.14 on my osx 10.8.1
but when use make -j the error info like this:

make[2]: gcc: Resource temporarily unavailable
gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -g -I/usr/local/Cellar/pcre/8.31/include -DNDK_SET_VAR -DNDK_UPSTREAM_LIST -DNDK_SET_VAR -DNDK_SET_VAR -DNDK_SET_VAR -DLUA_DEFAULT_PATH='"/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua"' -DLUA_DEFAULT_CPATH='"/usr/local/openresty/lualib/?.so"' -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/http -I src/http/modules -I src/os/unix -I ../ngx_devel_kit-0.2.17/objs -I objs/addon/ndk -I /Users/xiangchao/Downloads/ngx_openresty-1.2.4.14/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.0 -I ../ngx_lua-0.7.9/src/api -I objs
-o objs/ngx_modules.o
objs/ngx_modules.c
make[2]: gcc: Resource temporarily unavailable
make[2]: *** wait: No child processes. Stop.
make[2]: *** Waiting for unfinished jobs....
make[2]: *** wait: No child processes. Stop.
make[1]: *** [build] Error 2
make: *** [all] Error 2

it seems that more process to built it case an error ...

ngx_openresty-1.7.0.1 does not compile on Max OSX 10.9.2

Here is the error reported during the 'make'

objs/ngx_modules.o \
-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/pcre-8.33/lib -L/Users/kmarellapudi/LetsDoIt/ngx_openresty-1.7.0.1/build/luajit-root/usr/local/openresty/luajit/lib -lluajit-5.1 -lm -pagezero_size 10000 -image_base 100000000 -lpcre -lssl -lcrypto -lz

Undefined symbols for architecture x86_64:
"_SSL_CTX_set_next_protos_advertised_cb", referenced from:
_ngx_http_ssl_merge_srv_conf in ngx_http_ssl_module.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [objs/nginx] Error 1
make[1]: *** [build] Error 2
make: *** [all] Error 2

I did follow the special instruction for darwin users about installing pcre.

make fail for ngx_openresty-1.0.10.48

i'm fresher in mgx_openresty ;-(
env:

  • mac 10.7.3
  • ngx_openresty-1.0.10.48

steps:

error as:
Undefined symbols for architecture x86_64:
"_pcre_free_study", referenced from:
_ngx_http_lua_ngx_re_match in ngx_http_lua_regex.o
_ngx_http_lua_ngx_re_gmatch in ngx_http_lua_regex.o
_ngx_http_lua_ngx_re_sub_helper in ngx_http_lua_regex.o
_ngx_http_lua_ngx_re_gmatch_iterator in ngx_http_lua_regex.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [objs/nginx] Error 1
make[1]: *** [build] Error 2
make: *** [all] Error 2

i lost some Prerequisites?!

configure error on centos 5.6 64bit

hi agentzh

wenn i try to configure ngx_openresty-0.8.54.5 with luajit i get the following error. (note that the include and lib dirs are there and there are no other lua packages installed on this system) here is the output of configure. any clues?:

./configure     --user=nobody --group=nobody     --with-http_stub_status_module     --with-http_ssl_module     --without-mail_pop3_module     --without-mail_imap_module     --without-mail_smtp_module     --without-http_geo_module     --without-http_memcached_module     --without-http_empty_gif_module     --without-http_autoindex_module     --without-http_fastcgi_module     --without-http_scgi_module     --without-http_uwsgi_module     --without-http_drizzle_module     --without-http_xss_module     --without-http_form_input_module     --without-http_encrypted_session_module     --without-http_array_var_module     --without-http_redis2_module     --without-http_auth_request_module     --without-http_rds_json_module     --without-http_upstream_keepalive_module     --with-luajit
[bd@centi ngx_openresty-0.8.54.5]$ ./configure     --user=nobody --group=nobody     --with-http_stub_status_module     --with-http_ssl_module     --without-mail_pop3_module     --without-mail_imap_module     --without-mail_smtp_module     --without-http_geo_module     --without-http_memcached_module     --without-http_empty_gif_module     --without-http_autoindex_module     --without-http_fastcgi_module     --without-http_scgi_module     --without-http_uwsgi_module     --without-http_drizzle_module     --without-http_xss_module     --without-http_form_input_module     --without-http_encrypted_session_module     --without-http_array_var_module     --without-http_redis2_module     --without-http_auth_request_module     --without-http_rds_json_module     --without-http_upstream_keepalive_module     --with-luajit
platform: linux (linux)
cp -r bundle/ build/
cd build
cd LuaJIT-2.0.0-beta7
make PREFIX=/usr/local/openresty/luajit
==== Building LuaJIT 2.0.0-beta7 ====
make -C src
make[1]: Entering directory `/home/bd/tmp/ngx_openresty-0.8.54.5/build/LuaJIT-2.0.0-beta7/src'
HOSTCC    buildvm.o
HOSTCC    buildvm_asm.o
HOSTCC    buildvm_peobj.o
HOSTCC    buildvm_lib.o
HOSTCC    buildvm_fold.o
HOSTLINK  buildvm
BUILDVM   lj_vm.s
ASM       lj_vm.o
CC        lj_gc.o
BUILDVM   lj_ffdef.h
CC        lj_err.o
CC        lj_char.o
BUILDVM   lj_bcdef.h
CC        lj_bc.o
CC        lj_obj.o
CC        lj_str.o
CC        lj_tab.o
CC        lj_func.o
CC        lj_udata.o
CC        lj_meta.o
CC        lj_state.o
CC        lj_dispatch.o
CC        lj_vmevent.o
CC        lj_api.o
CC        lj_lex.o
CC        lj_parse.o
CC        lj_ir.o
CC        lj_opt_mem.o
BUILDVM   lj_folddef.h
CC        lj_opt_fold.o
CC        lj_opt_narrow.o
CC        lj_opt_dce.o
CC        lj_opt_loop.o
CC        lj_opt_split.o
CC        lj_mcode.o
CC        lj_snap.o
CC        lj_record.o
CC        lj_crecord.o
BUILDVM   lj_recdef.h
CC        lj_ffrecord.o
CC        lj_asm.o
CC        lj_trace.o
CC        lj_gdbjit.o
CC        lj_ctype.o
CC        lj_cdata.o
CC        lj_cconv.o
CC        lj_ccall.o
CC        lj_carith.o
CC        lj_clib.o
CC        lj_cparse.o
CC        lj_lib.o
CC        lj_alloc.o
CC        lib_aux.o
BUILDVM   lj_libdef.h
CC        lib_base.o
CC        lib_math.o
CC        lib_bit.o
CC        lib_string.o
CC        lib_table.o
CC        lib_io.o
CC        lib_os.o
CC        lib_package.o
CC        lib_debug.o
CC        lib_jit.o
CC        lib_ffi.o
CC        lib_init.o
AR        libluajit.a
CC        luajit.o
BUILDVM   ../lib/vmdef.lua
DYNLINK   libluajit.so
LINK      luajit
OK        Successfully built LuaJIT
make[1]: Leaving directory `/home/bd/tmp/ngx_openresty-0.8.54.5/build/LuaJIT-2.0.0-beta7/src'
==== Successfully built LuaJIT 2.0.0-beta7 ====
make install PREFIX=/usr/local/openresty/luajit DESTDIR=/home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root
==== Installing LuaJIT 2.0.0-beta7 to /usr/local/openresty/luajit ====
mkdir -p /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/bin /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.0 /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/share/man/man1 /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib/pkgconfig /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/share/luajit-2.0.0-beta7/jit /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/share/lua/5.1 /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib/lua/5.1
cd src && install -m 0755 luajit /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/bin/luajit-2.0.0-beta7
cd src && test -f libluajit.a && install -m 0644 libluajit.a /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib/libluajit-5.1.a || :
rm -f /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib/libluajit-5.1.so.2.0.0 /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib/libluajit-5.1.so /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib/libluajit-5.1.so
cd src && test -f libluajit.so && \
      install -m 0644 libluajit.so /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib/libluajit-5.1.so.2.0.0 && \
      ldconfig -n /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib && \
      ln -sf libluajit-5.1.so.2.0.0 /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib/libluajit-5.1.so && \
      ln -sf libluajit-5.1.so.2.0.0 /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib/libluajit-5.1.so || :
/bin/sh: line 2: ldconfig: command not found
cd etc && install -m 0644 luajit.1 /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/share/man/man1
cd etc && sed -e "s|^prefix=.*|prefix=/usr/local/openresty/luajit|" luajit.pc > luajit.pc.tmp && \
      install -m 0644 luajit.pc.tmp /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib/pkgconfig/luajit.pc && \
      rm -f luajit.pc.tmp
cd src && install -m 0644 lua.h lualib.h lauxlib.h luaconf.h lua.hpp luajit.h /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.0
cd lib && install -m 0644 bc.lua v.lua dump.lua dis_x86.lua dis_x64.lua vmdef.lua /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/share/luajit-2.0.0-beta7/jit
==== Successfully installed LuaJIT 2.0.0-beta7 to /usr/local/openresty/luajit ====

Note: the beta releases deliberately do NOT install a symlink for luajit
You can do this now by running this command (with sudo):

  ln -sf luajit-2.0.0-beta7 /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/bin/luajit

export LUAJIT_LIB='/home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib'
export LUAJIT_INC='/home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.0'
cd ..
cd nginx-0.8.54
./configure --prefix=/usr/local/openresty/nginx \
  --with-cc-opt='-O2' \
  --add-module=../echo-nginx-module-0.36rc3 \
  --add-module=../ngx_devel_kit-0.2.17 \
  --add-module=../set-misc-nginx-module-0.21 \
  --add-module=../ngx_lua-0.1.6rc9 \
  --add-module=../headers-more-nginx-module-0.15rc1 \
  --add-module=../srcache-nginx-module-0.12rc4 \
  --add-module=../memc-nginx-module-0.12rc1 \
  --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib' \
  --user=nobody --group=nobody --with-http_stub_status_module --with-http_ssl_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_geo_module --without-http_memcached_module --without-http_empty_gif_module --without-http_autoindex_module --without-http_fastcgi_module --without-http_scgi_module --without-http_uwsgi_module
checking for OS
 + Linux 2.6.18-238.9.1.el5 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.1.2 20080704 (Red Hat 4.1.2-50)
checking for gcc -pipe switch ... found
checking for --with-ld-opt="-Wl,-rpath,/usr/local/openresty/luajit/lib" ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for sched_setaffinity() ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for SO_SETFIB ... not found
configuring additional modules
adding module in ../echo-nginx-module-0.36rc3
 + ngx_http_echo_module was configured
adding module in ../ngx_devel_kit-0.2.17
 + ngx_devel_kit was configured
adding module in ../set-misc-nginx-module-0.21
 + ngx_http_set_misc_module was configured
adding module in ../ngx_lua-0.1.6rc9
checking for LuaJIT library in /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib and /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.0 (specified by the LUAJIT_LIB and LUAJIT_INC env) ... not found
        ./configure: error: the ngx_lua addon requires the lua or luajit library and LUAJIT_LIB is defined as /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/lib and LUAJIT_INC /home/bd/tmp/ngx_openresty-0.8.54.5/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.0, but we cannot find LuaJIT there.
failed to run command: ./configure --prefix=/usr/local/openresty/nginx \
  --with-cc-opt='-O2' \
  --add-module=../echo-nginx-module-0.36rc3 \
  --add-module=../ngx_devel_kit-0.2.17 \
  --add-module=../set-misc-nginx-module-0.21 \
  --add-module=../ngx_lua-0.1.6rc9 \
  --add-module=../headers-more-nginx-module-0.15rc1 \
  --add-module=../srcache-nginx-module-0.12rc4 \
  --add-module=../memc-nginx-module-0.12rc1 \
  --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib' \
  --user=nobody --group=nobody --with-http_stub_status_module --with-http_ssl_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --without-http_geo_module --without-http_memcached_module --without-http_empty_gif_module --without-http_autoindex_module --without-http_fastcgi_module --without-http_scgi_module --without-http_uwsgi_module

thx in advance, bernd

POST method processing issue with error_page and echo

I've got strange behaviour when configuring error_pages with named locations and echo. My actual setup is a bit more complex, but I've pared it down to this test setup.

I'm running this on ngx_openresty-1.4.1.1, on SL6.3.

Configuration diff against stock nginx.conf:

diff -u nginx.conf~ nginx.conf
--- nginx.conf~ 2013-08-01 16:05:48.925000016 +0200
+++ nginx.conf  2013-08-01 16:29:29.050999715 +0200
@@ -4,7 +4,7 @@
 
 #error_log  logs/error.log;
 #error_log  logs/error.log  notice;
-#error_log  logs/error.log  info;
+error_log  logs/error.log  info;
 
 #pid        logs/nginx.pid;
 
@@ -33,7 +33,7 @@
     #gzip  on;
 
     server {
-        listen       80;
+        listen       12111;
         server_name  localhost;
 
         #charset koi8-r;
@@ -45,6 +45,26 @@
             index  index.html index.htm;
         }
 
+location /forbidden {
+    return 403;
+}  
+error_page 400 @e400;
+error_page 403 @e403;
+
+location @e400 {
+    default_type application/json;
+    echo  '{"error": 400}';
+    echo_flush;
+}
+
+location @e403 {
+    default_type application/json;
+    echo '{"error": 403 }';
+    echo_flush;
+}
+
+
+
         #error_page  404              /404.html;
 
         # redirect server error pages to the static page /50x.html

Now when I post some data ("foobar") against /forbidden I get the 403 as expected, but additionally Nginx sends me a 400 and complains that "foobar" is not a valid HTTP method.

Ie.:

% curl -d 'payload' -XPOST 'http://localhost:12111/forbidden'
{"error": 403 }

Error log:

2013/08/01 16:36:50 [info] 23615#0: *1 client sent invalid method while reading client pipelined request line, client: 127.0.0.1, server: localhost, request: "payload"
2013/08/01 16:36:50 [info] 23615#0: *1 shutdown() failed (107: Transport endpoint is not connected) while reading client pipelined request line, client: 127.0.0.1, server: localhost, request: "payload"

Network trace courtesy wireshark:

POST /forbidden HTTP/1.1
User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Host: localhost:12111
Accept: */*
Content-Length: 7
Content-Type: application/x-www-form-urlencoded

payloadHTTP/1.1 403 Forbidden
Server: ngx_openresty/1.4.1.1
Date: Thu, 01 Aug 2013 14:37:57 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive

10
{"error": 403 }

0

{"error": 400}

So, the 403 is expected, but it seems strange that Nginx wants to parse the POST body as another HTTP request (and sends a 400 naturally).

Conversely, if error_pages are configured as regular files (not echo() in named locations) only the 403 gets delivered, as expected:

+location /forbidden {
+    return 403;
+}  
+location /error {
+    default_type application/json;
+    root html;
+}
+error_page 400 /error/400.json;
+error_page 403 /error/403.json;



POST /forbidden HTTP/1.1
User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.14.0.0 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Host: localhost:12111
Accept: */*
Content-Length: 7
Content-Type: application/x-www-form-urlencoded

payloadHTTP/1.1 403 Forbidden
Server: ngx_openresty/1.4.1.1
Date: Thu, 01 Aug 2013 14:46:03 GMT
Content-Type: application/json
Content-Length: 16
Connection: keep-alive
ETag: "51fa742d-10"

{"error": 403 }

is there a start, stop, reload script

hi i am running openresty server, and wanted to know if there is a rc.d/nginx script to start/stop/reload the server as /usr/local/openresty/nginx/sbin/nginx just starts it.

thanks

Upgrade lua-cjson to 2.1.0

There have been a number of updates upstream.

Version 2.1.0 (Mar 1 2012)

  • Added cjson.safe module interface which returns nil after an error
  • Improved Makefile compatibility with Solaris make

Version 2.0.0 (Jan 22 2012)

  • Improved platform compatibility for strtod/sprintf locale workaround
  • Added option to build with David Gay's dtoa.c for improved performance
  • Added support for Lua 5.2
  • Added option to encode infinity/NaN as JSON null
  • Fixed encode bug with a raised default limit and deeply nested tables
  • Updated Makefile for compatibility with non-GNU make implementations
  • Added CMake build support
  • Added HTML manual
  • Increased default nesting limit to 1000
  • Added support for re-entrant use of encode and decode
  • Added support for installing lua2json and json2lua utilities
  • Added encode_invalid_numbers() and decode_invalid_numbers()
  • Added decode_max_depth()
  • Removed registration of global cjson module table
  • Removed refuse_invalid_numbers()

Version 1.0.4 (Nov 30 2011)

  • Fixed numeric conversion under locales with a comma decimal separator

init_by_lua&init_by_lua_file nginx: [emerg] unknown directive "init_by_lua" in ...

test init_by_lua&init_by_lua_file directive at http & server & location section ,all failed:
output : [emerg] unknown directive init_by_lua&...

I compiled openresty with the configure:
./configure --prefix=/opt/openresty --with-luajit --without-http_redis2_module --with-http_drizzle_module --with-http_iconv_module -j2
at my mac.

While connecting to Drizzle db through jdbc ?It will through below error??

While connecting to Drizzle db through jdbc ?It will through below error??

Connection connection = DriverManager.getConnection("jdbc:mysql:thin://192.168.0.92:3306/db1");

Please help me......
-----Error::
java.sql.SQLNonTransientConnectionException: Could not connect: Connection refused: connect
at org.drizzle.jdbc.internal.SQLExceptionMapper.get(SQLExceptionMapper.java:97)
at org.drizzle.jdbc.DrizzleDriver.connect(DrizzleDriver.java:97)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at test.doGet(test.java:65)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1008)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.drizzle.jdbc.internal.common.QueryException: Could not connect: Connection refused: connect
at org.drizzle.jdbc.internal.mysql.MySQLProtocol.(MySQLProtocol.java:145)
at org.drizzle.jdbc.DrizzleDriver.connect(DrizzleDriver.java:88)
... 21 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.drizzle.jdbc.internal.mysql.MySQLProtocol.(MySQLProtocol.java:142)
... 22 more

Difference between openresty and tengine

I saw that Taobao originally sponsored the development of openresty but now they focus on tengine. What's the relationship between openresty and tengine? Is there a place that compares the 2?

Feature-request: multi-cosocket receive

Can you please implement a multi-cosocket receive?

which, data, status=multi_cosocket_receive(websocket, othersocket);

"which" tells me from which socket the data was received.

So I can wait for websocket and maybe redis without spawning an extra light-thread.

luacosocket udp support planned?

Hello!

Do you have any plans to implement lua cosocket sending UDP support? I'm searching for a solution to send (no receive required) using UDP to 3 different destinations (we would try to implement library for each destination, however we need lua cosocket support).

-STATSD server - send increment data notification to StatsD server (https://github.com/etsy/statsd)
function send(data)
local host = "127.0.0.1";
local port = 8125;
local prefix = "applications.apache.modsecurity."
local send_data = prefix .. data .. ":1|c"
udp_sock = socket.udp();
udp_sock:sendto(send_data, host, port)
end

-MULTICAST to multiple receivers using UDP as here (we would like to notify multiple computers to reconfigure firewall):
https://github.com/sam-github/luasocket/blob/unstable/samples/mcsend.lua

-SYSLOG - send to remote syslog server using IP UDP we would try to implement Sendsyslog(ip,port,facility,severity,message) like in http://www.luteus.biz/Download/LoriotPro_Doc/LUA/LoriotPro-LUA_Scripting/LUA_functions_EN/lp_SendSyslog_EN.htm)

ngx_openresty-1.4.3.3 安装失败

/opt/ngx_openresty-1.4.3.3/build/nginx-1.4.3/../ngx_lua-0.9.2/src/ngx_http_lua_regex.c:1870: undefined reference to `pcre_free_study'

Update to nginx 1.7.1

I am really looking forward to the support for syslog that comes with nginx 1.7.1. Is there any chance of getting openresty updated to be based off of it instead of 1.7.0?

md5.lua: undefined symbol: MD5_Init

Hello,

After moving to a new server i'm getting this error:

2012/12/29 16:12:06 [error] 31191#0: *3 lua entry thread aborted: runtime error: /usr/local/openresty/lualib/resty/resty/md5.lua:46: /usr/local/lib/libluajit-5.1.so.2: undefined symbol: MD5_Init
stack traceback:
coroutine 0:
[C]: in function '__index'
/usr/local/openresty/lualib/resty/resty/md5.lua:46: in function 'new'

every time when new() is called

local resty_md5 = require "resty.md5"
local md5 = resty_md5:new()

Linux 3.2.0-35-generic #55-Ubuntu SMP Wed Dec 5 17:42:16 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

ngx_openresty-1.2.4.14
nginx-1.2.6
no special options have been added to ./configure

openssl 0.9.8 has also been installed.

I can't figure our what has changed and why did it work on previous server.

Please help!

Make error

System : Ubuntu 12.04 x86-64
openresty : cloned from github

I got these errors:

./util/mirror-tarballs
: No such file or directory
make: *** [all] Error 127

But the directory is there.

Make fails with Passenger module on Mavericks

Hi! I'd like to use openresty for our stack upgrade to support nginx as a reverse proxy for redis cached content. I can't get 1.5.12 to compile on Mavericks when I add the Passenger 4.0.48 module. Make runs w/o error if I remove the Passenger add-module option.

Configure:
./configure --prefix=/usr/local/openresty --with-cc-opt="-Wno-deprecated-declarations -Wno-unused-const-variable -I/usr/local/Cellar/luajit/2.0.3/include/luajit-2.0" --with-ld-opt="-L/usr/local/Cellar/luajit/2.0.3/lib" --with-luajit --with-http_ssl_module --with-pcre=../pcre-8.35 --add-module=/Users/louisgates/.rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.45/ext/nginx

Error:
cc -c -pipe -O -Wall -Wextra -Wpointer-arith -Wconditional-uninitialized -Wno-unused-parameter -g -Wno-deprecated-declarations -Wno-unused-const-variable -I/usr/local/Cellar/luajit/2.0.3/include/luajit-2.0 -DNDK_SET_VAR -DNDK_UPSTREAM_LIST -DNDK_SET_VAR -DNDK_SET_VAR -DNDK_SET_VAR -DLUA_DEFAULT_PATH='"/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua"' -DLUA_DEFAULT_CPATH='"/usr/local/openresty/lualib/?.so"' -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/http -I src/http/modules -I src/os/unix -I ../ngx_devel_kit-0.2.19/objs -I objs/addon/ndk -I /usr/local/src/ngx_openresty-1.5.12.1/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.1 -I ../ngx_lua-0.9.7/src/api -I /Users/louisgates/.rvm/gems/ruby-1.9.3-p429/gems/passenger-4.0.45/ext -I /usr/local/src/ngx_openresty-1.5.12.1/../pcre-8.35 -I objs
-o objs/src/core/nginx.o
src/core/nginx.c
In file included from src/core/nginx.c:8:
In file included from src/core/ngx_config.h:34:
In file included from src/os/unix/ngx_darwin_config.h:60:
objs/ngx_auto_config.h:253:1: error: unknown type name 'openresty'
openresty/
^
objs/ngx_auto_config.h:253:10: error: expected identifier or '('
openresty/
^
src/core/nginx.c:559:9: error: use of undeclared identifier 'environ'
environ = env;
^
src/core/nginx.c:826:22: error: use of undeclared identifier 'environ'
ngx_os_environ = environ;
^
4 errors generated.
make[2]: *** [objs/src/core/nginx.o] Error 1
make[1]: *** [build] Error 2
make: *** [all] Error 2

My uname output: Darwin Louiss-Mac-mini.local 13.2.0 Darwin Kernel Version 13.2.0: Thu Apr 17 23:03:13 PDT 2014; root:xnu-2422.100.13~1/RELEASE_X86_64 x86_64

Any help is appreciated!

Why nginx log 502 status instead of 200 in access log


 location ~ ^/test {
        include uwsgi_params;
        uwsgi_pass 127.0.0.1:3031;
 }

I can always get "HTTP/1.1 200 OK" when I access the location above, but nginx always log 502 status instead of 200 in the access log. My uWSGI service works fine and it returns "HTTP/1.1 200 OK" when I directly access the address 127.0.0.1:3031.

All my other proxy service such as php-fpm do not have such a problem.

That's weird.

My openresty version: 1.2.6.6

request method in subrequest not honored by uwsgi module

Hey there,

this isn't directly related to OpenResty but i'll post here nevertheless. Maybe you can help as well. Otherwise just close as wontfix, please. We already filed the issue against uWSGI as well as Nginx:

While switching our Python WSGI Pyramid application stack
to uWSGI behind OpenResty we hit a road block when issuing
subrequests from Lua to the uWSGI application.

The code in ngx_http_uwsgi_module.c does not seem to honor
the request method when being in the context of a subrequest.
Instead, it seems to inherit the request method of the origin
request. On the other hand, the "echo-module" does just fine in this context.

We're using OpenResty 1.2.6.6 (Nginx 1.2.6), however switching
to OpenResty 1.2.7.5 (Nginx 1.2.7) makes no difference.

We prepared a wash & go buildout environment and a summary to reproduce this issue:

Thanks for looking into this!

Cheers,
Andreas.

链接LuaJIT-2.0.2的静态库报错,需要在./bundle/ngx_lua-0.9.2/config中加入-ldl参数

程序版本: ngx_openresty-1.4.3.4
操作系统: Ubuntu 12.04.1 LTS
编译器版本: gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Luajit版本: LuaJIT-2.0.2

编译时, 我想用静态库: libluajit-5.1.a
所以将 $LuaJIT_HOME/lib 下的_.so_全删了.

然后执行:
./configure --prefix=pwd --with-luajit=/opt/LuaJIT-2.0.2

报错:
./configure: error: ngx_http_lua_module requires the Lua or LuaJIT library and LUAJIT_LIB is defined as /opt/LuaJIT-2.0.2/lib and LUAJIT_INC (path for lua.h) /opt/LuaJIT-2.0.2/include/luajit-2.0, but we cannot find LuaJIT there.

在bundle/nginx-1.4.3/auto/feature的47行之后添加:
cat $NGX_AUTOTEST.c
echo "/bin/sh -c "$ngx_test" >> $NGX_AUTOCONF_ERR 2>&1"

调试发现真正的报错信息为:
/opt/LuaJIT-2.0.2/lib/libluajit-5.1.a(lj_clib.o): In function clib_getsym': /run/shm/ngx_openresty-1.4.3.4/build/LuaJIT-2.0.2/src/lj_clib.c:140: undefined reference to dlsym'
/opt/LuaJIT-2.0.2/lib/libluajit-5.1.a(lj_clib.o): In function clib_loadlib': /run/shm/ngx_openresty-1.4.3.4/build/LuaJIT-2.0.2/src/lj_clib.c:117: undefined reference to dlopen'

LuaJIT-2.0.2/lib/pkgconfig/luajit.pc 中:
Requires:
Libs: -L${libdir} -l${libname}
Libs.private: -Wl,-E -lm -ldl

链接阶段用静态库的话, 需要在gcc加 -ldl 参数..

修改./bundle/ngx_lua-0.9.2/config, 添加 -ldl 参数后编译成功. :-)

How to set stream into memcached by lua

location /image {
content_by_lua '
local uri =ngx.var.uri;

                    local res = ngx.location.capture("/memc", { args = { cmd="get", key = uri}}); 
                    if res.status == 200 then 
                            ngx.print((res.body)); 
                    else 
                            local res2 = ngx.location.capture("/innerimage", { args = { url = uri}}); 
                    if res2.status == 200 then 
                            local my_s = res2.body; 
                            ngx.location.capture("/memc", { args = { cmd="set", key = uri , val=my_s , exptime= 50000 }}); 
                            ngx.print(my_s); 

                    end 
        end 
            '; 
    } 

when i get pic from memcached, it's not correct code.
how can i put stream to memcahed by lua?

Heroku support

I've wanted to use ngx_openresty for awhile, but didn't want to have to support a server, compilation, etc. Heroku is my goto. Their buildpack mechanism allows you to package the necessary binaries with your application code, so that it can be deployed to their cloud environment easily.

I work a with cloud hosting solutions. Heroku has proven, thus far, to be the most open and supportive environment for any platform that can serve HTTP requests.

I put together a proof of concept buildpack for Heroku that supports ngx_openresty. Basically any application that has a nginx.conf at the application's root level will automatically be packaged as an OpenResty application. I've compiled OpenResty of have every single module (no MySQL, since Heroku uses Postgres).

The buildpack can be found here. Right now its supporting an earlier version (1.0.10.24) of ngx_openresty, but with a little work could be expanded. Also, please keep in mind that I am currently hosting the buildpack, so my S3 charges are being applied, so keep it minimal.

Any questions or thoughts are welcome. Thanks for the great platform.

[objs/nginx] Error 1 - Strange error

Hello,

This is my configure:

./configure --prefix=/opt/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --http-scgi-temp-path=/var/lib/nginx/scgi --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --with-http_gzip_static_module --user=www-data --group=www-data --without-mail_pop3_module --without-mail_imap_module --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-ipv6 --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_spdy_module --with-http_sub_module --with-http_xslt_module --with-mail --with-mail_ssl_module --add-module=modules/nginx-upstream-fair --add-module=modules/ngx_http_auth_pam_module-1.2 --add-module=modules/echo-nginx-module-0.54 --add-module=modules/nginx-dav-ext-module --add-module=modules/ngx_pagespeed --add-module=modules/ngx_devel_kit-0.2.19 --add-module=modules/lua-nginx-module

Btw, while compiling, i got this error, please help me. Thanks!

objs/addon/src/ngx_http_lua_phase.o: In function ngx_http_lua_inject_phase_api': /usr/local/src/ngx_openresty-1.7.0.1/modules/lua-nginx-module/src/ngx_http_lua_phase.c:85: multiple definition ofngx_http_lua_inject_phase_api'
objs/addon/src/ngx_http_lua_phase.o:/usr/local/src/ngx_openresty-1.7.0.1/modules/lua-nginx-module/src/ngx_http_lua_phase.c:85: first defined here
objs/addon/src/ngx_http_lua_uthread.o: In function ngx_http_lua_inject_uthread_api': /usr/local/src/ngx_openresty-1.7.0.1/modules/lua-nginx-module/src/ngx_http_lua_uthread.c:32: multiple definition ofngx_http_lua_inject_uthread_api'
objs/addon/src/ngx_http_lua_uthread.o:/usr/local/src/ngx_openresty-1.7.0.1/modules/lua-nginx-module/src/ngx_http_lua_uthread.c:32: first defined here
objs/addon/src/ngx_http_lua_timer.o: In function ngx_http_lua_inject_timer_api': /usr/local/src/ngx_openresty-1.7.0.1/modules/lua-nginx-module/src/ngx_http_lua_timer.c:44: multiple definition ofngx_http_lua_inject_timer_api'
objs/addon/src/ngx_http_lua_timer.o:/usr/local/src/ngx_openresty-1.7.0.1/modules/lua-nginx-module/src/ngx_http_lua_timer.c:44: first defined here
objs/addon/src/ngx_http_lua_config.o: In function ngx_http_lua_inject_config_api': /usr/local/src/ngx_openresty-1.7.0.1/modules/lua-nginx-module/src/ngx_http_lua_config.c:23: multiple definition ofngx_http_lua_inject_config_api'
objs/addon/src/ngx_http_lua_config.o:/usr/local/src/ngx_openresty-1.7.0.1/modules/lua-nginx-module/src/ngx_http_lua_config.c:23: first defined here
objs/addon/src/ngx_http_lua_worker.o: In function ngx_http_lua_inject_worker_api': /usr/local/src/ngx_openresty-1.7.0.1/modules/lua-nginx-module/src/ngx_http_lua_worker.c:22: multiple definition ofngx_http_lua_inject_worker_api'
objs/addon/src/ngx_http_lua_worker.o:/usr/local/src/ngx_openresty-1.7.0.1/modules/lua-nginx-module/src/ngx_http_lua_worker.c:22: first defined here
collect2: ld returned 1 exit status
make[2]: *** [objs/nginx] Error 1
make[2]: Leaving directory /usr/local/src/ngx_openresty-1.7.0.1/build/nginx-1.7.0' make[1]: *** [build] Error 2 make[1]: Leaving directory/usr/local/src/ngx_openresty-1.7.0.1/build/nginx-1.7.0'
make: *** [all] Error 2

1.2.7.5 prefix compile problem

Hi,

I try this:

./configure --prefix=/usr/local/LAMP/openresty/1.2.7.5 --with-luajit 

and get this error:

checking for LuaJIT library in /usr/local/src/ngx_openresty-1.2.7.5/build/luajit-root/usr/local/LAMP/openresty/1.2.7.5/luajit/lib and /usr/local/src/ngx_openresty-1.2.7.5/build/luajit-root/usr/local/LAMP/openresty/1.2.7.5/luajit/include/luajit-2.0 (specified by the LUAJIT_LIB and LUAJIT_INC env) ... not found

./configure: error: ngx_http_lua_module requires the Lua or LuaJIT library and LUAJIT_LIB is defined as /usr/local/src/ngx_openresty-1.2.7.5/build/luajit-root/usr/local/LAMP/openresty/1.2.7.5/luajit/lib and LUAJIT_INC (path for lua.h) /usr/local/src/ngx_openresty-1.2.7.5/build/luajit-root/usr/local/LAMP/openresty/1.2.7.5/luajit/include/luajit-2.0, but we cannot find LuaJIT there. failed to run command: ./configure --prefix=/usr/local/LAMP/openresty/1.2.7.5/nginx \...

Update: Sorry for the confusion, I mixed something up!

That compile error happened because I tried --with-ld-opt="-static" which does not seem to work and caused the error above.

Is there a way to compile the whole ngx_openresty statically, e.g. to use it in a chrooted environment?

Thank you!

Kind regards,

Thomas

update the configure script

every time run the configure script with params "--with-luajit", will rebuild the lua library.
we can check this library build or not, and using the exist library.

Example of how to build an RPM on Centos

Hi, I just built an RPM from openresty, thought I'd share the commands I used.

.PHONY: build

user=kevin
pcre_location=/home/$(user)/pcre-8.32
version=1.2.7
iteration=2
rpm=nginx-$(version)-$(iteration).x86_64.rpm
openresty_pkg=ngx_openresty-1.2.7.6
package=$(openresty_pkg).tar.gz

install:
    wget http://openresty.org/download/$(package)
    tar -zxvf $(package)
    mv $(openresty_pkg) openresty
    yum install -y s3cmd rpm-build perl pcre-devel --public-repos
    # xxx save this somewhere
    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz
    gem install fpm

build:
    mkdir -p /tmp/build
    cp -r openresty /tmp/build >/dev/null
    cd /tmp/build/openresty; \
        PATH=/sbin:$$PATH ./configure --with-luajit --prefix=/usr/local \
        --with-pcre=$(pcre_location)
    cd /tmp/build/openresty; \
        make
    cd /tmp/build/openresty; \
        make install DESTDIR=/tmp/openresty

rpm-clean:
    rm -rf $(rpm)

package: rpm-clean
    fpm -s dir -t rpm -n nginx -v $(version) --iteration $(iteration) -C /tmp/openresty usr

clean:
    rm -rf /tmp/openresty /tmp/build/openresty $(rpm)

SSL sockets

From HttpLuaModule TODO:

  • implement the SSL cosocket API.

body_filter_by_lua would hang sometimes

environ:
ubuntu 12.04
ngx_openresty-1.2.4.13

body_filter_by_lua 'ngx.arg[1] = string.upper(ngx.arg[1])'; in the HttpLuaModule docs works.
string.gsub works fine sometimes, when it does not work, the curl would get the correct content and then hang for a long time

I think the below configure would reproduce the bug.

        location / {
            root   html;
            body_filter_by_lua      'ngx.arg[1] = string.gsub(ngx.arg[1], "nginx", "x")';
        }

Make bundle fail

Hi

It seems that the link to patch Lua is down.

...
patching file src/http/ngx_http_request_body.c
patching file src/http/ngx_http_request.c
patching file src/http/ngx_http_request.h
Hunk #1 succeeded at 369 (offset 3 lines).
patching file src/http/modules/ngx_http_log_module.c
--2012-03-10 01:23:54-- http://www.lua.org/ftp/patch-lua-5.1.4-4
Resolving www.lua.org... 89.238.129.35, 2a02:40:41::5
Connecting to www.lua.org|89.238.129.35|:80... connected.
HTTP request sent, awaiting response... 404 Not found
2012-03-10 01:23:55 ERROR 404: Not found.
...

ngx_openresty-1.10.24 does not build under OSX

When linking the final objs/nginx,

Undefined symbols for architecture x86_64:
"_pcre_free_study", referenced from:
_ngx_http_lua_ngx_re_match in ngx_http_lua_regex.o
_ngx_http_lua_ngx_re_gmatch in ngx_http_lua_regex.o
_ngx_http_lua_ngx_re_sub_helper in ngx_http_lua_regex.o
_ngx_http_lua_cleanup_pcre_study_data in ngx_http_lua_regex.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[2]: *** [objs/nginx] Error 1

this was configured with a plain './configure' line.

Double ngx_http_auth_request_module cause compiling issue

I compiled ngx_openresty-1.5.12.1 get multiple definition of ngx_http_auth_request_module error at last gcc commond.
So I googled, and find out that ngx_http_auth_request_module is already included in offical nginx package since 1.5.4.
Is there any difference between the two version of ngx_http_auth_request_module?
And thanks for the effort on ngx_openresty.

REQ: leveldb library

A LuaLevelDBLibrary component would seem to fit this project really well, so, I don't know if this is currently planned or so far hadn't attracted much attention but I'd encourage such an endeavor.

make failed without openssl

./configure --with-debug --with-luajit --without-http_ssl_module

..... and make failed. For set-misc module need openssl, I didn't install openssl-dev.

make[1]: Leaving directory /root/work/ngx_openresty-1.0.10.44/build/lua-rds-parser-0.04' cd /root/work/ngx_openresty-1.0.10.44/build/nginx-1.0.10 && make make[1]: Entering directory/root/work/ngx_openresty-1.0.10.44/build/nginx-1.0.10'
make -f objs/Makefile
make[2]: Entering directory /root/work/ngx_openresty-1.0.10.44/build/nginx-1.0.10' gcc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Wunused-function -Wunused-variable -Wunused-value -g -O0 -DNDK_SET_VAR -DNDK_UPSTREAM_LIST -DNDK_SET_VAR -DNDK_SET_VAR -DNDK_SET_VAR -DLUA_DEFAULT_PATH='"/usr/local/openresty/lualib/?.lua"' -DLUA_DEFAULT_CPATH='"/usr/local/openresty/lualib/?.so"' -DNDK_SET_VAR -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_devel_kit-0.2.17/objs -I objs/addon/ndk -I /root/work/ngx_openresty-1.0.10.44/build/luajit-root/usr/local/openresty/luajit/include/luajit-2.0 -I objs -I src/http -I src/http/modules -I ../ngx_devel_kit-0.2.17/src -I src/mail \ -o objs/addon/src/ngx_http_set_hash.o \ ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c In file included from ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c:5: src/core/ngx_sha1.h:18:17: error: sha.h: No such file or directory In file included from ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c:5: src/core/ngx_sha1.h:22: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘ngx_sha1_t’ ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c: In function ‘ngx_http_set_misc_set_sha1’: ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c:28: error: ‘ngx_sha1_t’ undeclared (first use in this function) ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c:28: error: (Each undeclared identifier is reported only once ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c:28: error: for each function it appears in.) ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c:28: error: expected ‘;’ before ‘sha’ ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c:36: warning: implicit declaration of function ‘SHA1_Init’ ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c:36: error: ‘sha’ undeclared (first use in this function) ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c:37: warning: implicit declaration of function ‘SHA1_Update’ ../set-misc-nginx-module-0.22rc4/src/ngx_http_set_hash.c:38: warning: implicit declaration of function ‘SHA1_Final’ make[2]: *** [objs/addon/src/ngx_http_set_hash.o] Error 1 make[2]: Leaving directory/root/work/ngx_openresty-1.0.10.44/build/nginx-1.0.10'
make[1]: *** [build] Error 2
make[1]: Leaving directory `/root/work/ngx_openresty-1.0.10.44/build/nginx-1.0.10'
make: *** [all] Error 2

Why disable LUA_COMPAT_OPENLIB?

I noticed in lua-5.1.5-disable_lua50_compat.patch you have

#undef LUA_COMPAT_OPENLIB

Is there any specific reason to this? It prevents me from loading some modules, namely the ones that come with LuaSocket.

Can't use "require" in *_by_lua to load *.lua, but can use "loadfile"

I managed to statically cross compiling ngx_openresty-1.7.0.1 with patch and toolchain for my BCM4708 based router target, but has issue to use "require" function, but can use "loadfile" instead.

All local xxx = require "resty.xxx" in nginx.conf will cause errors:

2014/06/08 05:49:32 [notice] 10966#0: signal 17 (SIGCHLD) received
2014/06/08 05:49:32 [alert] 10966#0: worker process 9639 exited on signal 11 (core dumped)
2014/06/08 05:49:32 [notice] 10966#0: start worker process 13414

Core dumped can get form here and binary are here.

PS: lua_package_path is correct.

/usr/bin/arm-uclibc:

#!/bin/sh
export PATH=/home/crosstool-ng/x-tools/arm-lazyzhu-linux-uclibcgnueabi/bin:\$PATH
export CC=arm-linux-uclibcgnueabi-gcc
export CXX=arm-linux-uclibcgnueabi-g++
export CPP=arm-linux-uclibcgnueabi-cpp
export AR=arm-linux-uclibcgnueabi-ar
export RANLIB=arm-linux-uclibcgnueabi-ranlib
export LD=arm-linux-uclibcgnueabi-ld
export NM=arm-linux-uclibcgnueabi-nm
export STRIP=arm-linux-uclibcgnueabi-strip
export READELF=arm-linux-uclibcgnueabi-readelf
export OBJCOPY=arm-linux-uclibcgnueabi-objcopy
export OBJDUMP=arm-linux-uclibcgnueabi-objdump
export CROSS_PREFIX=/home/crosstool-ng/x-tools/arm-lazyzhu-linux-uclibcgnueabi/bin/arm-lazyzhu-linux-uclibcgnueabi-
exec "\$@"

And the cross compiling process:

cd /cross/arm-uclibc/src
[[ -d "zlib-1.2.8" ]] && rm -rf zlib-1.2.8
wget http://zlib.net/zlib-1.2.8.tar.gz -O -|tar xz

cd /cross/arm-uclibc/src
[[ -d "openssl-1.0.1h" ]] && rm -rf openssl-1.0.1h
wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz -O -|tar xz

cd /cross/arm-uclibc/src
[[ -d "pcre-8.35" ]] && rm -rf pcre-8.35
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.bz2 -O -|tar xj

cd /cross/arm-uclibc/src
[[ -d "ngx_openresty-1.7.0.1" ]] && rm -rf ngx_openresty-1.7.0.1
wget http://openresty.org/download/ngx_openresty-1.7.0.1.tar.gz -O -|tar xz

cd ngx_openresty-1.7.0.1
patch -p1 < ../ngx_openresty-1.7.0.1-static_cross_compilation_for_arm_architecture.patch

# precompile luajit
cd /cross/arm-uclibc/src/ngx_openresty-1.7.0.1/bundle/LuaJIT-2.1-20140607
export CC="/home/crosstool-ng/x-tools/arm-lazyzhu-linux-uclibcgnueabi/bin/arm-linux-uclibcgnueabi-gcc"
export CROSS_PREFIX="/home/crosstool-ng/x-tools/arm-lazyzhu-linux-uclibcgnueabi/bin/arm-lazyzhu-linux-uclibcgnueabi-"
make STATIC_CC=${CC} CROSS=${CROSS_PREFIX} \
  TARGET_CFLAGS=" -O2 -static -static-libgcc -static-libstdc++" TARGET_LDFLAGS=" -static"
make install PREFIX=/opt/luajit DESTDIR=/cross/arm-uclibc/src/ngx_openresty-1.7.0.1/bundle/luajit-root

cd /cross/arm-uclibc/src/ngx_openresty-1.7.0.1
arm-uclibc ./configure \
  --prefix=/opt \
  --with-ipv6 \
  --with-http_ssl_module \
  --with-http_spdy_module \
  --with-http_realip_module \
  --with-http_addition_module \
  --with-http_gunzip_module \
  --with-http_gzip_static_module \
  --with-http_auth_request_module \
  --with-http_random_index_module \
  --with-http_stub_status_module \
  --with-http_auth_request_module \
  --without-mail_pop3_module \
  --without-mail_imap_module \
  --without-mail_smtp_module \
  --without-lua_cjson \
  --without-lua_redis_parser \
  --without-lua_rds_parser \
  --with-cpu-opt=arm \
  --crossbuild=Linux:arm \
  --with-cc-opt=" -O2 -static -static-libgcc -static-libstdc++" \
  --with-ld-opt=" -static" \
  --with-endian=little \
  --with-int=4 \
  --with-long=4 \
  --with-long-long=8 \
  --with-ptr-size=4 \
  --with-sig-atomic-t=4 \
  --with-size-t=4 \
  --with-off-t=4 \
  --with-time-t=4 \
  --with-sys-nerr=132 \
  --with-luajit="/cross/arm-uclibc/src/ngx_openresty-1.7.0.1/build/luajit-root/opt/luajit" \
  --with-zlib=../zlib-1.2.8 \
  --with-openssl=../openssl-1.0.1h \
  --with-pcre \
  --with-pcre=../pcre-8.35 \
  --with-pcre-jit \
  --with-pcre-jit-static-fix

sed -i "/CFLAGS/s/ \-O //g" objs/Makefile
arm-uclibc make

Running on target:

# /opt/nginx/sbin/nginx -V
nginx version: openresty/1.7.0.1
built by gcc 4.6.4 (crosstool-NG 1.19.0)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-cc-opt=' -O2 -static -static-libgcc -static-libstdc++' --add-module=../ngx_devel_kit-0.2.19 --add-module=../echo-nginx-module-0.53 --add-module=../xss-nginx-module-0.04 --add-module=../ngx_coolkit-0.2rc1 --add-module=../set-misc-nginx-module-0.24 --add-module=../form-input-nginx-module-0.08 --add-module=../encrypted-session-nginx-module-0.03 --add-module=../srcache-nginx-module-0.27 --add-module=../ngx_lua-0.9.8 --add-module=../ngx_lua_upstream-0.02 --add-module=../headers-more-nginx-module-0.25 --add-module=../array-var-nginx-module-0.03 --add-module=../memc-nginx-module-0.14 --add-module=../redis2-nginx-module-0.11 --add-module=../redis-nginx-module-0.3.7 --add-module=../rds-json-nginx-module-0.13 --add-module=../rds-csv-nginx-module-0.05 --with-ld-opt='-Wl,-rpath,/cross/arm-uclibc/src/ngx_openresty-1.7.0.1/build/luajit-root/opt/luajit/lib -static' --with-ipv6 --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_stub_status_module --with-http_auth_request_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-cpu-opt=arm --crossbuild=Linux:arm --with-endian=little --with-int=4 --with-long=4 --with-long-long=8 --with-ptr-size=4 --with-sig-atomic-t=4 --with-size-t=4 --with-off-t=4 --with-time-t=4 --with-sys-nerr=132 --with-zlib=/cross/arm-uclibc/src/ngx_openresty-1.7.0.1/../zlib-1.2.8 --with-openssl=/cross/arm-uclibc/src/ngx_openresty-1.7.0.1/../openssl-1.0.1h --with-pcre --with-pcre=/cross/arm-uclibc/src/ngx_openresty-1.7.0.1/../pcre-8.35 --with-pcre-jit --with-pcre-jit-static-fix

有关RPC over http的想法

最近,我通过Thrift实现了一个RPC的客户端和服务端轻量级的框架。由于RPC无法穿透防火墙,故外网的客户端非常有可能无法调用服务器。IIS是支持RPC OVER HTTP,通过MS的介绍IIS也只是做一个PRXOY。因此,我就想到NGX有没有类似的模块。

Persistence, Global Variables

Hello,

had an idea of creating highly performance blob storage using openresty.

In order to do this I need 2 features, let me know if openresty supports this.

First one, can I have a persistent connection to redis shared among each connection? So I don't have to reconnect to redis on every request, but instead use one connection opened on server start.

Second one, if I open a file using lua at server start and store handle into a global variable, can I read random chunks (offset + length) on different requests? How does this work?

set cookie by Lua will change html MIME-TYPE

when I set nginx config like this
server {
......
set_by_lua $xyz "
ngx.header['Set-Cookie'] = {'___obj=123'}
return '123'
";
......
}

but I browse my html file by google chrome, it will be a download file not show on the browser. I check the html mime-type is application/octet-stream.

when I comment the set cookie, everything will be fine. Could you tell me why?

--with-zlib include relative path getting error

--with-zlib=../zlib-1.2.7

getting error:

make[3]: Leaving directory `/root/src/pcre-8.32'
cd ../zlib-1.2.7 \
        && make distclean \
        && CFLAGS="-O2 -fomit-frame-pointer -pipe " CC="gcc" \
                ./configure \
        && make libz.a
/bin/sh: line 0: cd: ../zlib-1.2.7: No such file or directory
make[2]: *** [../zlib-1.2.7/libz.a] Error 1

but when with absolute path, it's fine.

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.