![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
openresty
文章平均质量分 76
带鱼兄
爱在新空气,快乐每一天
展开
-
用openresty实现动态upstream
前言:此文的读者定义为对openresty有一定了解的读者。openresty官网:https://github.com/openresty/lua-nginx-module此文要讲什么:大家都知道openresty可以用ngx.location.capture和ngx.exec来实现内部跳转,下面要讲怎么将ngx.location.capture和ngx.原创 2016-11-03 23:37:58 · 14318 阅读 · 0 评论 -
openresty用header_filter_by_lua设置自定义HTTP头
header_filter_by_lua的说明:header_filter_by_luasyntax: header_filter_by_lua context: http, server, location, location ifphase: output-header-filterWARNING Since the v0.9.17 release, use of th原创 2016-11-13 15:32:33 · 18705 阅读 · 0 评论 -
openresty禁用304 Not Modified
先看一段代码:worker_processes 1;error_log logs/error.log;events { worker_connections 1024;}http { log_format main '$msec $status $request $request_time ' '$http_refe原创 2016-11-18 23:05:28 · 2571 阅读 · 0 评论 -
openresty扫描代码全局变量
在OpenResty中需要避免全局变量的使用,为此春哥写了一个perl小工具,可以扫描openresty lua代码的全局变量:https://github.com/openresty/openresty-devel-utils/blob/master/lua-releng#!/usr/bin/env perluse strict;use warnings;use Getopt:原创 2017-04-18 12:28:45 · 1999 阅读 · 0 评论 -
openresty设置error_page
准备:1.在当前路径建conf、logs、html目录2.将配置daiyu.conf放在conf中3.将一个404.jpg放html中4.启动命令为nginx -p `pwd` -c conf/daiyu.conf情形一:没用proxy_pass,直接通过lua返回user root;worker_processes 1;error_log logs/erro原创 2016-11-24 22:05:40 · 3874 阅读 · 0 评论 -
openresty在access_log打印自定义变量
期望:在access_log打印自定义变量define_error_codenginx配置:worker_processes 1;events { worker_connections 1024;}http { log_format main '[$time_local] $request $status $remote_addr $define_原创 2017-07-15 12:11:49 · 4227 阅读 · 0 评论 -
openresty执行阶段
openresty执行阶段1)set_by_lua2)rewrite_by_lua3)access_by_lua4)content_by_lua5)header_filter_by_lua6)body_filter_by_lua7)log_by_lua注意:content_by_lua和proxy_pass同属于 content 阶段,不要混用;原创 2017-08-21 22:47:55 · 1348 阅读 · 0 评论 -
proxy_pass_request_headers off的坑
举个例子,客户端访问80端口,服务器需要将请求转发至8080端口处理,我们希望将客户端传递的headers过滤,再设置内部转发请求header(test:"123"),坑(通过ngx.req.set_header设置的请求头,会被过滤): server { listen 80; location / {原创 2017-11-19 01:12:33 · 5962 阅读 · 0 评论 -
openresty中应用murmurHash
介绍:MurmurHash 是一种非加密型哈希函数,适用于一般的哈希检索操作。由Austin Appleby在2008年发明,并出现了多个变种,都已经发布到了公有领域(public domain)。与其它流行的哈希函数相比,对于规律性较强的key,MurmurHash的随机分布特征表现更良好。当前的版本是MurmurHash3,能够产生出32-bit或128-bit哈希值。较早的Murmu...原创 2019-08-01 22:30:23 · 2902 阅读 · 0 评论