openresty

nginx+lua+redis(openresty)配置

家住魔仙堡 提交于 2019-12-13 22:16:06
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> nginx+lua+redis(openresty)配置 2014-07-18 11:10 2494人阅读 评论 (1) 收藏 举报 方案一: 1.安装lua解释器 wget http://luajit.org/download/LuaJIT-2.0.2.tar.gz (http://luajit.org/download.html) 配置lua Lib和include/luajit-$version目录为环境变量 2.下载ngx_devel_kit和lua-nginx-module https://codeload.github.com/simpl/ngx_devel_kit/tar.gz/v0.2.19 ( https://github.com/simpl/ngx_devel_kit/tags) https://codeload.github.com/openresty/lua-nginx-module/tar.gz/v0.9.10 (https://github.com/openresty/lua-nginx-module/tags) 3.安装配置nginx http://nginx.org/download/nginx-1.4.7.tar.gz (http://nginx.org/en/download

Mac系统的openresty编译安装

*爱你&永不变心* 提交于 2019-12-12 16:51:55
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> [toc] ###依赖软件包安装 wget https://openresty.org/download/openresty-1.9.7.4.tar.gz brew update brew install pcre openssl pcre安装完成会提示如下 ==> Downloading https://homebrew.bintray.com/bottles/pcre-8.38.el_capitan.bottle ######################################################################## 100.0% ==> Pouring pcre-8.38.el_capitan.bottle.tar.gz /usr/local/Cellar/pcre/8.38: 203 files, 5.4M openssl安装完成会提示默认安装路径LDFLAGS 、CPPFLAGS Generally there are no consequences of this for you. If you build your own software and it requires this formula, you'll need to add to your

Is it possible to consolidate multiple responses and send one response in NGINX

久未见 提交于 2019-12-11 17:24:57
问题 I have Nginx/openresty and some other services running on one VM. Basically VM accepts requests on Openresty and then openresty forwards requests to appropriate service. e.g. below requests getting forwarded to ServiceA, ServiceB and ServiceC respectively. It is working fine. http://server:80/services/refA http://server:80/services/refB http://server:80/services/refC Now I need to expose a new endpoint which could get the responses from all services A, B and C. and then return one

Building openresty1.7.10.1 with luajit on windows

可紊 提交于 2019-12-09 22:42:08
Building openresty1.7.10.1 with luajit on windows using Cygwin, 在windows下用Cygwin下编译带Luajit的openresty 2013-11-27 15:39 815人阅读 评论 (0) 收藏 举报 (heeroz原创 )First install 32bit cygwin. Install packet: openssl zlib-dev pcre gcc-core perl readline openresty没有对Cygwin做兼容,我们需要自己来修改文件 Open bundle\lua-cjson and lua-rds-parser and lua-redis-parser three folder's Makefile for edit, Add those lines before “## ..... (Macports)” bundle\lua-cjson的,lua-rds-parser的,lua-redis-parser的Makefile里,“## ***OSX (Macports)”上面加入: [plain] view plain copy ifeq ($(OS),Windows_NT) LDFLAGS2 += -L../luajit-root/usr/local/openresty

openresty(nginx+lua)学习小记

风流意气都作罢 提交于 2019-12-09 22:41:52
出于技术储备的目的研究了下openresty,恩,收获不小,有一种在旧衣服里找到钱的快感,简单记录下自己可能会用到的知识点,做个备忘。 ###安装 仅限于Mac OSX系统,其他系统安装方式自行搜索 //推荐 brew tap homebrew/nginx brew install homebrew/nginx/openresty or brew install nginx-full --with-lua-module ###学习前准备 nginx.conf打开日志,方便查看lua脚本或配置本身的错误 access_log /usr/local/var/log/nginx/access.log; error_log /usr/local/var/log/nginx/error.log; nginx配置和lua脚本变化监听并重启nginx的程序,不然每次手动重启略麻烦,这里有一个 go版本 的 package main import ( "log" "os/exec" "github.com/fsnotify/fsnotify" ) func main() { watcher, err := fsnotify.NewWatcher() if err != nil { log.Fatal(err) } defer watcher.Close() done := make(chan

Debugging OpenResty and Nginx Lua scripts with Zer

北慕城南 提交于 2019-12-09 22:41:36
ZeroBrane By seeking, you will discover... Subscribe Debugging OpenResty and Nginx Lua scripts with ZeroBrane Studio 12 MAY 2014 ZeroBrane Studio has already been used to debug various Lua engines -- game frameworks (like Corona , Gideros , Moai , Love2d ), home automation devices , wireshark scripts , Adobe Lightroom plugins , and more -- but there have been several Lua environments that I haven't tried it on. One of them is OpenResty/Nginx Lua scripts. OpenResty is a web application server built around nginx, a very fast web server, that provides non-blocking IO with various backends (Redis,

fastdfs 使用原文件名下载

孤人 提交于 2019-12-08 09:49:17
fastdfs 使用原文件名下载 安装部署fastdfs 需求 openresty代替nginx 安装和配置openresty 安装部署fastdfs 可参考我的上一篇文章 fastdfs 单机多groupName部署和springboot区分环境上传 需求 由于fastdfs上传之后文件名使用的是框架编码的文件名所以下载的时候文件名不是原始的名称了。图片显示还好说,文档附件这种的无法忍。于是就有了这篇文章。 openresty代替nginx 通过在上传的时候将源文件名存表,在下载的时候可以在给nginx的请求中加?attname=来指定文件名。但是如果文件名是中文的,那么下载下来的文件都是url编码的(会有%)。所以需要使用openresty来代替nginx,这样就可以用Lua来转码了。 安装和配置openresty 下载组件 openresty-1.13.6.1、openssl-1.0.2q、pcre-8.42、zlib-1.2.11。这里有个坑,openresty的最新版不支持最新版的openssl。如果版本不对则会在gmake的时候报错。 解压后进入openresty目录开始安装 ./configure --prefix = /opt/openresty --with-luajit --with-http_stub_status_module --with-http_ssl

docker unit test setup

青春壹個敷衍的年華 提交于 2019-12-07 03:30:26
问题 I want to setup a unit test environment for my product. I have a web application build on nginx in Lua which use mysql and redis. I think docker will be good for this although i am new to docker . My application runs on centos server (production server). I am planning to setup different container for mysql,redis and webapp and then write UT application (unit test for Lua using Busted framework) in my mac (My development machine is MAC) or VM to test it. The UT application will talk to docker

openresty 前端开发序

房东的猫 提交于 2019-12-07 02:10:59
还记得第一次尝试前后端分离的时候,是使用nginx + react 构建的spa应用,后端是java,主要处理业务逻辑逻辑部分,返回json数据,在nginx里面配置好html + js纯静态文件,再通过反向代理到java后端,解决跨域问题,然后使用ajax来进行交互,模型很简单,也很有效 主要解决了几个问题 一、独立,由于前后端分离,在开发的时候完全可以互相独立,所谓独立,其实就是说前后端是属于两个项目,保存在各自的git仓库,提交代码既不会冲突,也不需要合并 二、解耦合,后端开发完成之后只需要提交代码,然后发布到测试环境,而前端只需要启动一个nginx然后反向代理到测试环境,就可以开始开发工作,就是这么简单 三、版本更新,在项目上线之后通常需要继续迭代更新,这个时候就提现出前后端分离的价值了,前端样式排版更新,只需要更新前端,对后端几乎没有影响,那么只需要测试前端,避免了部分开发人员的失误,在前端更新的时候,导致后端服务的不可用,而由于前后端分离,并独立部署,提高了后端的稳定性,又保持了前端的多变性 但是也带来了一些其他的问题,主要逻辑都是js编写,成了胖客户端,在网速不佳的时候,体验不是很好,还有一个就是seo问题,当然我之前做的主要针对微信端,而且也不考虑seo,所以即使这样也能接受,那么就只剩下前端加载性能的问题。 前端我是这样解决的 使用webpack + gulp

从构建分布式秒杀系统聊聊限流特技

谁都会走 提交于 2019-12-06 21:00:58
前言 俗话说的好,冰冻三尺非一日之寒,滴水穿石非一日之功,罗马也不是一天就建成的。两周前秒杀案例初步成型,分享到了中国最大的同 性友网站-码云。同时也收到了不少小伙伴的建议和投诉。我从不认为分布式、集群、秒杀这些就应该是大厂的专利,在互联网的今天无论什么时候都要时刻武装自己,只有这样,也许你的春天就在明天。 在开发秒杀系统案例的过程中,前面主要分享了队列、缓存、锁和分布式锁以及静态化等等。缓存的目的是为了提升系统访问速度和增强系统的处理能力;分布式锁解决了集群下数据的安全一致性问题;静态化无疑是减轻了缓存以及DB层的压力。 限流 然而再牛逼的机器,再优化的设计,对于特殊场景我们也是要特殊处理的。就拿秒杀来说,可能会有百万级别的用户进行抢购,而商品数量远远小于用户数量。如果这些请求都进入队列或者查询缓存,对于最终结果没有任何意义,徒增后台华丽的数据。对此,为了减少资源浪费,减轻后端压力,我们还需要对秒杀进行限流,只需保障部分用户服务正常即可。 就秒杀接口来说,当访问频率或者并发请求超过其承受范围的时候,这时候我们就要考虑限流来保证接口的可用性,以防止非预期的请求对系统压力过大而引起的系统瘫痪。通常的策略就是拒绝多余的访问,或者让多余的访问排队等待服务。 限流算法 任何限流都不是漫无目的的,也不是一个开关就可以解决的问题,常用的限流算法有:令牌桶,漏桶。 令牌桶 令牌桶算法是网络流量整