首页 > 配置文件 > ts-lua??�a��helloworld

ts-lua??�a��helloworld

2013年9月30日     浏览数:522 发表评论 阅读评论

ts-lua??�a��

ts-lua??�a��???e??e�?e?�a?�a??a��a��cs�a?�a??remapcs�??�a��i??a??a�??�????a��a�s?��cs�remapaSYe??i??a��header?�?a??a�?transforma��c?�c��c��i??a??c�?lua??�a��a?Zi??a?saS?cs�a��c?�a?�a?�?��e?�a��a??a?�?z?a??c��a??

e??c��cs�githuba?�a?�a??i?shttps://github.com/portl4t/ts-lua/

e?�a????�a��a?sc�?a?�ssla�?luai???��e?�luac�???�5.1a�?c?Zi??a???Z?e??a??c�?luajiti???��e?�a?�cZ�luajite�?a??a��a�?c�?c?�??�e��e??a��

a��a?�c?�e?�a��e?�i?Y

a?�e�?a?�a�?c�?a��e?�a?�a?�a??a�??�?cs�ATSi??a??a�?a?�e�????a�?c�?e�?cs�Makefilei??a?Ya??a�?c�?tsxsa???�?a??cs�c?�e?�a��e?�ts-lua??�a��??�e?�i??a��i?s

git clone https://github.com/portl4t/ts-lua.git
cd ts-lua/src/
tsxs -o tslua.so -lssl -llua ts*.c
sudo tsxs -o tslua.so -i

c��?z?a��a?�i?s

zym@zymtest1 ~ $     git clone https://github.com/portl4t/ts-lua.git
fatal: c��?��e�?a?� 'ts-lua' a�?c�?a�?a??i??a?�a?�a?????a?�a??c�?c��a?�a��
zym@zymtest1 ~ $     cd ts-lua/src/
zym@zymtest1 ~/ts-lua/src $     tsxs -o tslua.so -lssl -llua ts*.c
    compiling ts_lua_atomic.c -> ts_lua_atomic.lo
    compiling ts_lua.c -> ts_lua.lo
    compiling ts_lua_cached_response.c -> ts_lua_cached_response.lo
    compiling ts_lua_client_request.c -> ts_lua_client_request.lo
    compiling ts_lua_client_response.c -> ts_lua_client_response.lo
    compiling ts_lua_context.c -> ts_lua_context.lo
    compiling ts_lua_hook.c -> ts_lua_hook.lo
    compiling ts_lua_http.c -> ts_lua_http.lo
    compiling ts_lua_misc.c -> ts_lua_misc.lo
ts_lua_misc.c: a??a�??��a�?ts_lua_debuga��a?�:
ts_lua_misc.c:42:5: e��a�Si?s?�?a??a��c��a??a?????a?�a??a��e??a��c��a??e�?a?�?????�a?�?�?a??a?�cs�a�za?� [-Wformat-security]
ts_lua_misc.c: a??a�??��a�?ts_lua_errora��a?�:
ts_lua_misc.c:52:5: e��a�Si?s?�?a??a��c��a??a?????a?�a??a��e??a��c��a??e�?a?�?????�a?�?�?a??a?�cs�a�za?� [-Wformat-security]
    compiling ts_lua_server_request.c -> ts_lua_server_request.lo
    compiling ts_lua_server_response.c -> ts_lua_server_response.lo
    compiling ts_lua_transform.c -> ts_lua_transform.lo
    compiling ts_lua_util.c -> ts_lua_util.lo
    linking -> tslua.so
zym@zymtest1 ~/ts-lua/src $     sudo tsxs -o tslua.so -i
    installing tslua.so -> /usr/lib64/trafficserver/plugins/tslua.so
zym@zymtest1 ~/ts-lua/src $

aY?c?�e�?c?�

ts-lua??�a��???remap??�a��i????�a��a?Se??cs�c?�e?�?�?a????�a?sa?�a�?e�??Z?a?�i??a??a??c�?a�?e?�e�?e�?c?�aY?c?�cs�a??e��a?�i??a??c�?libloader??�a��e?�e??luaa?�i????�a��e�?c?�/etc/trafficserver/plugin.configa��a?�i?s

/usr/lib64/trafficserver/plugins/libloader.so /usr/lib64/liblua.so

a?�e�?a??ATSa?Zi??a??a��a��remapa??c�?lua??�a��cs�cZ?a??a��??�a��a?�e�?ATSa�?c�?a?�a?�sslcs�?�????a��i??e�?e��??�a��a?�i?�

helloworld from Lua

a?�e?????a?�a??c��a?�cs�lua??�a��i??c��?��a��????��????��??�e?�a�zc�?a��a?Z400cs�e?�a�zi????�a��a?�e�?a??a�?a??/tmp/helloworld.luai?s

function send_response()
  -- *****************************************************************
  -- a��?z?a?�e?�e�?cs�e??i??a??a�?e�?a�?ts.ctxa?�a??a�?cs�?��??�???a��
  -- ts.client_response.header['Testzym'] = ts.ctx['status']

  -- ??�a��aS�i????�?�?i?�a��a??e?�a�za�?i?s
  ts.client_response.header['Cache-Control'] = 'max-age=10'
  ts.client_response.header['Server'] = 'ATS/5.1.0'
  return 0
end

function read_response()
  http_status = ts.server_response.header.get_status()
  ts.debug(string.format('server_response status = %d', http_status))
  if http_status >= 400 then
    -- servere?�a�za?�e��e??cs�c��?z?

    -- ***************************************************************
    -- a��?z?e?�e�?c��a?Zc��?�?c?�a??c��cs�a?????i??a??a�?c??a?�a?�ts.ctxa?�i?s
    --ts.ctx['status'] = http_status

    -- ??�a��a??e?�e�?a��a��a?�c��c�???�a�?cs�?��a��i??a�?a??c�?a??a?�
    ts.hook(TS_LUA_HOOK_SEND_RESPONSE_HDR, send_response)
  end
  return 0
end

function do_remap()
  -- ??�a��cs�e��c�?i??e?�e�???�a��c��READ_RESPONSE_HDRe?�a??c�?hooka?�a??a�??��
  -- e?�a??c�??????�ATSe?�??????aS?a�?c�?e?�a�za�?cs�?��a��?��e??cs�
  ts.hook(TS_LUA_HOOK_READ_RESPONSE_HDR, read_response)
  return 0
end

a?�?�?remap.configi??a?�a?�e?�a????�a��i?s

regex_map http://(.*)/ http://$1/ @plugin=/usr/lib64/trafficserver/plugins/tslua.so @pparam=/tmp/helloworld.lua

?��e??traffic_line -xa?Zi??e��a?�a??a??c�Y?�?i?s

zym@zymtest1 ~/ts-lua/src $ echo -ne "GET http://zymlinux.net/notfound HTTP/1.0\r\n\r\n" | netcat -i 1 localhost 8080
HTTP/1.0 404 Not Found
Date: Mon, 30 Sep 2013 09:48:21 GMT
Server: ATS/5.1.0
Content-Length: 211
Content-Type: text/html; charset=iso-8859-1
Age: 2
Via: http/1.1 zymlinux.net (ApacheTrafficServer/4.0.1 [cMsSf ])
Cache-Control: max-age=10

< !DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /~zym/notfound was not found on this server.</p>
</body></html>
zym@zymtest1 ~/ts-lua/src $

?��c��

e?�a??a?�a�?a??a��??�a��a?�a��a�?i??a?�???a�?c�?e?za????�?�??�?a��i????�a��a??a�?a??Luae�s??�a?�a�????a?�a?�e?�e�?c�?C???a?scs�a�?a??a��?�?a�scs�a?�a�?i??a?�e�?i?shttps://github.com/portl4t/ts-lua/ example/ a�? business/ c��a?�a?�cs�a?�a�?a��

分类: 配置文件 标签:
  1. info
    2014年5月30日14:09 | #1

    [May 30 15:36:04.791] {0x2b72da5c08c0} STATUS: opened /usr/local/ats/var/log/trafficserver/diags.log
    [May 30 15:36:04.791] {0x2b72da5c08c0} NOTE: updated diags config
    [May 30 15:36:04.795] Server {0x2b72da5c08c0} NOTE: cache clustering disabled
    [May 30 15:36:04.809] Server {0x2b72da5c08c0} NOTE: ip_allow.config updated, reloading
    [May 30 15:36:04.821] Server {0x2b72da5c08c0} NOTE: cache clustering disabled
    [May 30 15:36:04.822] Server {0x2b72da5c08c0} NOTE: logging initialized[15], logging_mode = 3
    [May 30 15:36:04.824] Server {0x2b72da5c08c0} NOTE: loading plugin ‘/usr/local/ats/libexec/trafficserver/libloader.so’
    [May 30 15:36:04.846] Server {0x2b72da5c08c0} NOTE: traffic server running
    [May 30 15:36:06.590] Server {0x2b72db945940} NOTE: cache enabled
    [May 30 15:37:25.887] Server {0x2b72e00ff940} WARNING: Could not add rule at line #242; Aborting!
    [May 30 15:37:25.887] Server {0x2b72e00ff940} WARNING: [ReverseProxy] Can’t load plugin “/usr/local/ats/libexec/trafficserver/tslua.so” – liblua.so: cannot open shared object file: No such file or directory at line 242
    [May 30 15:37:25.887] Server {0x2b72e00ff940} WARNING: something failed during BuildTable() — check your remap plugins!
    [May 30 15:37:25.887] Server {0x2b72e00ff940} WARNING: failed to reload remap.config, not replacing!

    remap.config的配置是这样的

    regex_map www .baidu. com 116.28.77.39 @plugin=tslua.so @pparam=/tmp/1.lua

    禁止输入网站只能把h t t p忽略了

    不知道是不是本本不兼容
    ts的版本是4.0.2

  2. 永豪
    2014年6月12日15:33 | #2

    Can’t load plugin “/usr/local/ats/libexec/trafficserver/tslua.so” – liblua.so: cannot open shared object file: No such file or directory at line 242

    说明啥??

  1. 本文目前尚无任何 trackbacks 和 pingbacks.
advertisement blocker for chrome software development company description software development company in ahmedabad software development company in austria software development company in bangalore software development company in baroda software development company in canada software development company in chandigarh software development company in coimbatore software development company in delhi