Reload Original PagePrint PageEmail Page

nginx lua httpclient | 2hei's site

首页

>

linux

,

nginx

> nginx lua as http client

首先感谢agentzh的辛苦大作,这里使用了openresty的版本。

1. 编译openresty


wget http://openresty.org/download/ngx_openresty-1.2.8.6.tar.gz
tar xzvf ngx_openresty-1.2.8.6.tar.gz
cd ngx_openresty-1.2.8.6/
./configure --with-luajit
make
make install

2.获取lua http client


git clone https://github.com/liseen/lua-resty-http

3. nginx vhost配置

cat 2hei.net.conf

lua_package_path ‘/usr/local/openresty/lualib/resty/?.lua;;’;
server {
listen 80;
server_name 2hei.net;

location /http_clinet{
resolver 8.8.8.8;
default_type ‘text/plain’;
content_by_lua ‘
ngx.say(“url_params: “, ngx.var.arg_url)
local http = require “resty.http
local hc = http:new()

local ok, code, headers, status, body = hc:request {
url = “http://2hei.net/test.html?url=”..ngx.var.arg_url,
method = “GET”,
}

ngx.say(ok)
ngx.say(code)
ngx.say(body)
‘;
}
}

本文的评论功能被关闭了.

::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::