nginx_lua nginx路由分发

发布时间:2017-04-08 16:39:48 阅读:882次

多个网站共用同一套代码

nginx.conf中server_name多个域名

    location = /root.txt {
        proxy_set_header  Host  $host;
        proxy_set_header  X-real-ip $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass "http://www.test.com/index.php?m=index&c=index&a=root";
    }   

这样访问每个网站的root.txt文件不一样

http://outofmemory.cn/code-snippet/14396/nginx-and-lua

    location ^~ /api/{
        proxy_pass http://api.www.com/;
    }

   #访问 http://www.test.com/api/login/qq_with_password

   #相当于访问 http://api.www.com/login/qq_with_password

   location = /member/checkorder.php {
        proxy_pass http://test.www.com/home/order/index;
    }   

    location = /member/checkphone.php {
        proxy_pass http://test.www.com/home/order/phone;
    }   

    location = /member/checkcode.php {
        proxy_pass http://test.www.com/home/order/login;
    }   

    location = /member/checkmember.php{
        #proxy_pass http://test.newwww.com/member/checkmember.php;
        default_type "text/html";
        content_by_lua_file /app/www/lua/checkmember.lua;
        break;
    }   

[root@web_beta2 conf]# nginx -V
nginx version: nginx/1.9.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/app/nginx/ --with-ld-opt=-Wl,-rpath,/app/luajit/lib/ --add-module=../ngx_devel_kit-master/ --add-module=../lua-nginx-module-master/ --with-http_ssl_module
[root@web_beta2 conf]#

cat nginx.conf

lua_package_path "/app/www/lua/lib/?.lua;;";
include /app/nginx/conf/vhost/*.conf;

可用

http://blog.51cto.com/kevinhao/1739503

https://www.cnblogs.com/yjf512/archive/2012/03/27/2419577.html

https://github.com/openresty/lua-nginx-module/releases/tag/v0.10.11

http://www.ttlsa.com/nginx/nginx-modules-ngx_lua/

http://blog.csdn.net/sanshi0815/article/details/39547337

https://github.com/openresty/echo-nginx-module/releases/tag/v0.61

http://blog.csdn.net/andybegin/article/details/8729480

http://blog.csdn.net/testcs_dn/article/details/51461999

https://www.cnblogs.com/dongxiao-yang/p/5312285.html

http://blog.csdn.net/a11101171/article/details/41622843

https://www.cnblogs.com/huangye-dream/p/3777004.html


http://openresty.org/en/routing-mysql-queries-based-on-uri-args.html

http://jinnianshilongnian.iteye.com/blog/2186448

http://blog.csdn.net/ygm_linux/article/details/53534933

https://www.cnblogs.com/gccbuaa/p/7018287.html

http://jinnianshilongnian.iteye.com/blog/2186448

http://www.ttlsa.com/nginx/nginx-and-lua/

http://blog.51cto.com/rfyiamcool/1243004

http://blog.csdn.net/ygm_linux/article/details/53561133

可以做什么

安装lua

root@bananapi /home/pi/nginx-lua# apt-get install lua5.1

root@bananapi /home/pi/nginx-lua# apt-get install liblua5.1-0-dev

https://www.oschina.net/question/12_45735

echo nginx module

Nginx模块Lua-Nginx-Module学习笔记

http://www.cnblogs.com/tinywan/p/6534151.html

--add-module=../echo-nginx-module-0.60 \ --add-module=../lua-nginx-module-0.10.7 \ --add-module=../redis2-nginx-module-0.13 \

安装openresty

http://www.jb51.net/article/61451.htm

lua基础教程

http://www.runoob.com/lua/lua-basic-syntax.html

NGINX + LUA实现复杂的控制

http://outofmemory.cn/code-snippet/14396/nginx-and-lua

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询
下一篇:logstash2.4.0

转载请注明:nginx_lua nginx路由分发 出自老鄢博客 | 欢迎分享