"""

#user  nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; server {
listen 80;
server_name localhost;
charset utf-8;
#charset koi8-r; #access_log logs/host.access.log main; #location / {
# root html;
# index index.html index.htm;
#}
location /one {
default_type 'text/html';
content_by_lua_block {
local function encodeBase64(source_str)
local b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
local s64 = ''
local str = source_str while #str > 0 do
local bytes_num = 0
local buf = 0 for byte_cnt=1,3 do
buf = (buf * 256)
if #str > 0 then
buf = buf + string.byte(str, 1, 1)
str = string.sub(str, 2)
bytes_num = bytes_num + 1
end
end for group_cnt=1,(bytes_num+1) do
local b64char = math.fmod(math.floor(buf/262144), 64) + 1
s64 = s64 .. string.sub(b64chars, b64char, b64char)
buf = buf * 64
end for fill_cnt=1,(3-bytes_num) do
s64 = s64 .. '='
end
end return s64
end
local salt = "78t2cs5nim6fpy"
local address = "www.7893015.com"
local base = encodeBase64(address)
local str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
local str2 = "GsW8O7iy1FS02VEIbjwzmH3fZQUBq5T9hrl4CvgNnRMDupYAJokK+ecadtL/P6xX"
ans = ""
for i=1,#base do
local one = string.sub(base,i,i)
local num = string.find(str1,one)
two = string.sub(str2,num,num)
ans = ans..two
end
local timestamp = os.time()
tmp = "d="..ans.."&t="..timestamp.."&v="..salt
local rightsign = ngx.md5(tmp)
local url = "/two?".."d="..ans.."&t="..timestamp.."&s="..rightsign
html = string.format(
[[
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<meta http-equiv="refresh" content="61;url=http://www.baidu.com">
<title></title>
</head><body>
<!--<h1>Service Temporarily Unavailable</h1>
<p>The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.</p>-->
<a href="" id="baidu"></a>
<script type="text/javascript">
baidu.href = "%s" ;
//IE
if(document.all) {
document.getElementById("baidu").click();
}
//Other Browser
else {
var e = document.createEvent("MouseEvents");
e.initEvent("click", true, true);
document.getElementById("baidu").dispatchEvent(e);
}
</script>
</body></html>
]],url
)
ngx.say(html)
}
} location /two {
default_type 'text/html';
content_by_lua_block {
local function decodeBase64(str64)
local b64chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
local temp={}
for i=1,64 do
temp[string.sub(b64chars,i,i)] = i
end
temp['=']=0
local str=""
for i=1,#str64,4 do
if i>#str64 then
break
end
local data = 0
local str_count=0
for j=0,3 do
local str1=string.sub(str64,i+j,i+j)
if not temp[str1] then
return
end
if temp[str1] < 1 then
data = data * 64
else
data = data * 64 + temp[str1]-1
str_count = str_count + 1
end
end
for j=16,0,-8 do
if str_count > 0 then
str=str..string.char(math.floor(data/math.pow(2,j)))
data=math.fmod(data,math.pow(2,j))
str_count = str_count - 1
end
end
end
local last = tonumber(string.byte(str, string.len(str), string.len(str)))
if last == 0 then
str = string.sub(str, 1, string.len(str) - 1)
end
return str
end
local salt = "78t2cs5nim6fpy"
local arg = ngx.req.get_uri_args()
local address = arg["d"]
local timestamp = arg["t"]
local sign = arg["s"]
if address and timestamp and value then
ngx.exit(403)
end
tmp = "d="..address.."&t="..timestamp.."&v="..salt
local rightsign = ngx.md5(tmp)
if sign ~= rightsign then
ngx.exit(403)
end
local time_out = 600
local time_now = os.time()
if tonumber(timestamp)+time_out<time_now then
ngx.exit(403)
end
local str1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
local str2 = "GsW8O7iy1FS02VEIbjwzmH3fZQUBq5T9hrl4CvgNnRMDupYAJokK+ecadtL/P6xX"
ans = ""
for i=1,#address do
local one = string.sub(address,i,i)
local num = string.find(str2,one)
two = string.sub(str1,num,num)
ans = ans..two
end
url = decodeBase64(ans)
html = string.format(
[[
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<style>a:hover,a:visited{color:#337FFD;} </style>
<title></title></head><body>
<p align="center"></p>
<p align="center"><b><font style="font-size: 30pt">
<script type="text/javascript">
function checkurl(){
window.location.href="https://%s";
}
</script>
<br><br><br>
<center> <a id="BAIDU" href="https://www.baidu.com/?Open=normal&BaiduPartner=360&BaiduVIP=73499" title="360维护网络健康计划:浏览器安全检查通过,请点击进入。" onclick="checkurl();return false;" style="background: #077727;padding: 10px 40px;margin: 15px;color: #fff;border-radius:8px;cursor: pointer;text-decoration:none;">浏览器安全检查通过,请点击进入</a>
</center>
</body></html>
]],url
)
ngx.say(html)
}
}
#error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }
"""

用 openresty 编写 lua的更多相关文章

  1. Openresty编写Lua代码一例

    1.前段时间纠结了很久,一直弄不清lua和tomcat的联系.一直认为是lua调用tomcat的接口才可使用,后面才明白过来,进入了一个误区,lua本身就是一门独立的脚本语言.在openresty里面 ...

  2. OpenResty(nginx+lua) 入门

    OpenResty 官网:http://openresty.org/ OpenResty 是一个nginx和它的各种三方模块的一个打包而成的软件平台.最重要的一点是它将lua/luajit打包了进来, ...

  3. (转)OpenResty(nginx+lua) 开发入门

    原文:https://blog.csdn.net/enweitech/article/details/78519398 OpenResty 官网:http://openresty.org/  Open ...

  4. CentOS安装OpenResty(Nginx+Lua)开发环境

    一.简介 OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库.第三方模块以及大多数的依赖项.用于方便地搭建能够处理超高并发.扩展性极高 ...

  5. 给lnmp一键包中的nginx安装openresty的lua扩展

    lnmp一键包(https://lnmp.org)本人在使用之后发现确实好用,能帮助我们快速搭建起lnmp.lamp和lnmpa的web生产环境,因此推荐大家可以多试试.但有的朋友可能需要使用open ...

  6. 【原创】大叔问题定位分享(36)openresty(nginx+lua)中获取不到post数据,ngx.req.get_body_data返回nil

    openresty(nginx+lua)中获取不到post数据,ngx.req.get_body_data返回nil This function returns nil if the request ...

  7. 搭建OpenResty(Nginx+Lua)

    这篇文章是一个多月前写的,当时之所以搭建这个是为了最大程度上发挥Nginx的高并发效率(主要是结合lua脚本),参考的话,主要参考张开涛先生写的跟开涛学Nginx+lua系列文章,地址为:https: ...

  8. [转]使用 C 编写 Lua 模块

    Lua 作为一种小巧的语言,一般都是嵌入到 C/C++ 中作为扩展语言,但是也可以作为独立的脚本语言使用,并且可以使用 C/C++ 编写扩展模块.在参考资料 [1] 中有怎样用 C/C++ 编写模块的 ...

  9. openresty安装lua和nginx相关

    server{ listen ; server_name a.com; index index.php; root /usr/share/nginx/html; location / { if (!- ...

随机推荐

  1. Blazor+Dapr+K8s微服务之开发环境调试

    1         安装Dapr开发调试环境 1.1         Dapr 完整安装模式不支持开发调试 在上一篇随笔<Blazor+Dapr+K8s微服务之服务调用>中,我们通过为每个 ...

  2. Freemarker基本语法

    一.概念 Freemarker是一款模板引擎,并用来输出文本,网页或配置文件等. 二.语法 2.1 注释 <!-- 在页面可以看的到 --> <#-- 在页面看不到 --> 2 ...

  3. Python爬虫(二)——发送请求

    1. requests库介绍 ​ 在python中有许多支持发送的库.比如:urlib.requests.selenium.aiohttp--等.但我们当前最常用的还是requests库,这个库是基于 ...

  4. COM笔记-包容与聚合

    COM不支持实现继承的原因在于这种继承方式将使得一个对象的实现同另外一个对象的实现紧紧地关联起来.在这种情况下,当基类的实现被修改后,派生类将无法正常运行而必须被修改.这就是为什么一些用C++编写大型 ...

  5. 使用VSCode创建第一个VUE项目

    vue init webpack vue_test回车,然后输入工程名称vue_test vue:Missing space before value for key 'components' 原因是 ...

  6. C# 检测某版本VC++是否安装

    一.根据微软的产品号GUID,调用msi.dll class Program { static void Main(string[] args) { if (GetProcuct("{GUI ...

  7. JDBC中的元数据

    在我编写JDBC代码的时候:出现很多的重复的代码,有没有什么办法让我们能够编写出更加通用的JDBC代码呢?使用元数据,元数据能够让我们编写出更加通用的JDBC代码.什么是元数据呢?(三种元数据)1)连 ...

  8. 单例模式-案例Runtime

    package d.create_type_single; import java.io.IOException; /** * Runtime类就是使用的单例:并且是饿汉式 * (原因考虑是因为:多线 ...

  9. urllib3中学到的LRU算法

    介绍 urllib3._collections.py::RecentlyUserContainer类,是一个线程安全的Dict类容器,用来维护一定数量(maxsize)的Key-Value映射, 当数 ...

  10. 将视图批量新增到PowerDesigner中并以model图表的形式展示

    1:需求 数据库中的所有视图大概64个左右,都需要新增到PowerDesigner中,以图表(model)的形式给展示出来,如下: 2:问题点: 由于2020年春节期间病毒的原因,我们需要远程办公,新 ...