Installation instructions of Nginx + LuaJIT catch the Header / Body of Request-Response

Tram Ho

Installation instructions Nginx + LuaJIT catch Header # tuanduong122

My problem: Sometimes I don’t know which Internet trick it inserts a bad header into the system. Or meet some bitter APIs that were handed over – the partner told me to receive the new code, but I don’t know how it works. I will insert nginx (front / back) to catch Header, Body how it works. From there Mr. Sys will understand the system more (miserable).

Step 1: Install the basic library that supports nginx:

Step 2: Install / Prepare LuaJIT

Set temporary environment variables

Step 3: Install nginx and libraries:

Create boot file for nginx (init file)

Test nginx syntax

Add nginx to systemctl and restart

Clean junk when installing:

Step4: Configure LUA test

(Can skip this step and go to STEP 5 – here I want to test lua oke activity yet)

Add this location to nginx (can skip this step and copy your config file in the step below – STEP 5):

vim /opt/nginx/nginx.conf

Test the nginx syntax and reload

TEST LUA:

Step 5: Configure log Header / Body

Configuration full nginx.conf

Check again to check nginx #nginx_syntax

Step: Test POST for example

Read log accesss:

Analysis of Results:

PRINT_REQUEST_BODY: { x22DUONGANHTUAN_BODY x22: x22123 x22}

PRINT_REQUEST_HEADER:host = tuanduong122.wordpress.com content-type = application / x-www-form-urlencoded tuanda = hehehe accept = / content-length = 27 user-agent = curl / 7.29.0″

PRINT_RESPONSE_HEADER: “content-length = 20 set-cookie = JSESSIONID = C94254D1F47723462F60222FE865D9FB; Path = /; HttpOnly content-type = text / html; charset = ISO-8859-1 connection = keep-alive”

PRINT_RESPONSE_BODY: “APACHE TOMCAT8 BODY x0A”

Other: Lua Show Request Body as Response

Lua_Nginx: https://github.com/openresty/lua-nginx-module

Share the news now

Source : Viblo