2011-09-20 81 views
0

一些移動網關正在將自定義標頭傳遞到我的網站。這些頭文件以各種格式傳遞,有時是x-msisdn,有時是x-up-calling-line-id等等。我如何記錄以自定義日誌格式傳遞的所有標題?自定義LogFormat - 記錄所有標頭

+0

你不能只與Apache和做到這一點mod_log_config。你可以用mod_security – symcbean

回答

0

通過Apache HTTPD我不知道如何記錄所有標題 - 只有如何記錄一個你知道的標題。

使用標準的Apache httpd模塊mod_log_config,您可以在CustomLog指令中指定以下選項。

%{Foobar} i發送到服務器的請求中Foobar:標題行的內容。其他模塊(例如mod_headers)所做的更改會影響此操作。

但是你可以在JSP中做到這一點(如果這是你偶然使用的是什麼)

<!-- method used to send request 
<%= request.getMethod() %> 

URI of the request 
<%= request.getRequestURI() %> 

    <% 
    /*This method returns an enumeration of all the header names this 
     request contains.*/  
    java.util.Enumeration names = request.getHeaderNames(); 
    while (names.hasMoreElements()) { 
    String hname = (String)names.nextElement(); 
    %> 

    <%= hname %> 
    <%= request.getHeader(hname) %> 
    <% 
    } 
    %> 
--!> 
0

您也可以嗅探網絡接口來做到這一點。

Wireshark的具有tshark的(易於得到安裝tshark的) tshark的「TCP端口80和(((IP [2:2] - ((IP [0] & 0xf)< < 2)) - ((TCP [ 12] & 0xf0)>> 2))!= 0)'-R'http.request.method ==「GET」|| http.request.method == 「HEAD」」

(從http://andy.wordpress.com/2008/07/10/sniffing-http/ tshark的上方傳來是tethereal的新名稱)

或使用類似https://github.com/caesar0301/http-sniffer