web網關配置手冊

web網關配置手冊

web網關的配置數據基本上都是存在於數據庫中,可通過clt -r命令將配置數據導出成xml文件,修改後再更新到數據庫中clt -u。

主要的配置如下:

 

一、 內網URL的配置(轉向proxy的域名,該配置只適合添加域名

該配置涉及三個文件http-client.xml、header-filter-request.xml、hostresolver.xml

http-client.xml 配置url的指向

將需要指向proxyurl填寫到這裏

stringsetinnerProxyUrls=Str.createSet("*.*.uni-info.com.cn","*.wap.wo.com.cn",…………)

 

stringspecialUrl = Str.concat(Str.concat(HttpReq.getProtocol(),"://"), Str.concat(HttpReq.getHost(), HttpReq.getPath()),Str.concat("?", HttpReq.getQuery()));

------此語句用來處理識別URL中存在?問號

 

if(Str.setContains(innerProxyUrls, HttpReq.getHost()) ||Str.setContains(innerProxyUrls, fullUrl) || Str.setContains(innerProxyUrls,dirUrl))

{

                    return"httpproxy";

        }

匹配以上域名的url,則轉向"httpproxy"的配置

<cs:Config Name="httpproxy"><Proxy Host="10.184.73.140"Port="8000" ProtocolVersion="*"PersistentConnection="true"/></cs:Config>

10.184.73.140proxyIP地址,端口是8000

 

    elseif(HttpReq.hostMatch("mmsc.myuni.com.cn")|| HttpReq.hostMatch("192.168.30.180") ||HttpReq.hostMatch("mmsc.monternet.com"))

        {

             return"mmsc";

        }

匹配mmsc.myuni.com.cn192.168.30.180mmsc.monternet.com的,都轉向" mmsc "彩信中心地址的配置

<cs:Config Name="mmsc">

    <ProxyHost="10.184.73.180" Port="8080"ProtocolVersion="*" PersistentConnection="false" />

</cs:Config>

10.184.73.180是彩信中心的IP地址,端口是8080

 

其他默認的指向default,即表示出公網。

       else

           return "default";

<cs:Config Name="default"Default="true">

    <Proxy Host="DIRECT" ProtocolVersion="*"PersistentConnection="true"/>

</cs:Config>

 

header-filter-request.xml 配置請求中的http頭信息

stringsetinnerProxyUrls = Str. createSet("*.*.uni-info.com.cn","*.wap.wo.com.cn",…………)

送到proxy的都要傳遞手機號,這一塊兒的配置跟http-client一致。

 

     Mem.setConfigParams(Msid.toString(Auth.getMsisdn()),bearerType, Ip.toString(HttpReq.getTerminalIp()), Ip.toString(Auth.getGgsnIp()));

            return "httpproxy";

     }

匹配以上域名的轉到httpproxy配置,其中“x-up-calling-line-id”代表手機號。

  <cs:Config Name="httpproxy"Default="false">

        <HeaderFilterRequestConfig>

            <Add>

                 <Header Name="x-up-calling-line-id"Value="{0}"/>

                 <HeaderName="x-up-bear-type" Value="{1}"/>

                 <HeaderName="x-forwarded-for" Value="{2}"/>

                 <HeaderName="x-source-id" Value="{3}"/>

             </Add>

        </HeaderFilterRequestConfig>

 

各個參數說明:

手機號碼:x-up-calling-line-id

手機IP地址:x-forwarded-for

瀏覽器類型:user-agent

User-ProfileURIx-wap-profile

接入承載方式:x-up-bear-type

GGSN地址:x-source-id

 

如果要刪除以上某些字段信息,則在<add>……</add>中去掉改字段即可。

 

如果要刪除User-Agentx-wap-profile等信息,則需要寫成以下格式:

<Remove>

    <Header Name="User-Agent"/>

    <Header Name="x-wap-profile"/>

</Remove>

 

hostresolver.xml內網域名解析

由於內網域名不需要解析,直接轉向proxy,將需要指向proxy的域名添加到hostresolver.xml的以下位置中。

<FreeHostList>

<Itemhost="*.wap.uni-info.com.cn"/>

<Itemhost="*.wap.wo.com.cn"/>

………………….

</FreeHostList>

 

 

以上配置無需手動修改,應使用httpproxy腳本導入,腳本會自動修改以上三個文件,具體操作如下:(注意:該方法只適用於添加域名指向proxy,長url只能手工添加,方法見第二節

登錄DBU1,進入/opt/httpproxy目錄,編輯list.txt文件,寫入所有需要指向proxy的url地址(包括原來的和新增的),如:

*.*.uni-info.com.cn

*.wap.wo.com.cn

*.mclient.uni-info.com.cn

*.uni-info.com.cn

10.123.254.*

10.184.68.51

…………

每一行是一條域名數據。

 

 

然後執行命令進行全量導入

./intranet.shlist.txt true

 

 

list.txt列表編寫方法:

clt -r http-client導出來,把stringset innerProxyUrls = Str.createSet(。。。。。)裏邊的列表搞出來,做成list.txt,一行一條url

注意,這一步只是爲了保證列表是現網最新的數據,如果能保證list.txt的內容已是最新的,可以不做,直接在後邊追加新域名。

最快的替換方法是使用editplus工具,將"",""替換爲回車。然後掐頭去尾雙引號 再把要添加的url追加到結尾,將list.txt上傳到 /opt/httpproxy下,執行 

./intranet.shlist.txt true 

 

二、 內網URL的配置(全路徑的url指向proxy)

clt -r http-client

http-client.xml

將要指向proxy的url全路徑添加到如下藍色位置:

stringsetproxyUrls = Str.createSetIgnoreCase(

"http://gwap.yes3g.com/gwap/gl_mccyc/index.jsp",

"http://gwap.yes3g.com/gwap/gl_mjqxz/index.jsp",

"http://gwap.yes3g.com/gwap/gl_fyttkx/index.jsp",

"http://gwap.yes3g.com/gwap/gl_jcqxdt/index.php",

… … … …

if(Str.setContains(proxyUrls,fullUrl) || Str.setContains(proxyUrls, dirUrl) || Str.setContains(proxyUrls,specialUrl))

    {

         return "httpproxy";

}

三、 增加傳遞明文手機號碼

登錄DBU

clt -rheader-filter-request

header-filter-request.xml

將需要傳遞明文手機號碼的url添加到如下位置,這裏增加的域名是除了以上在innerProxyUrls列表中要轉向proxy的內網地址之外的需要傳遞手機號的域名列表。

stringset onlineHall =Str.createSetIgnoreCase("wap.10010.com","mob.10010.com",………….);

return "onlineHall";

其轉向的是

    <cs:ConfigName="onlineHall">

        <HeaderFilterRequestConfig>

            <Add>

                 <HeaderName="X-Nokia-Gateway-Id" Value="{0}/{1}/{2}"/>

                 <HeaderName="X-Nokia-BEARER" Value="{3}"/>

                 <HeaderName="x-up-bear-type" Value="{3}" />

                 <HeaderName="X-Nokia-MaxDownlinkBitrate" Value="{4}"/>

                 <HeaderName="X-Nokia-MaxUplinkBitrate" Value="{5}"/>

                <HeaderName="x-up-calling-line-id" Value="{6}"/>

                 <HeaderName="x-forwarded-for" Value="{7}"/>

                 <HeaderName="x-source-id" Value="{8}"/>

             </Add>

        </HeaderFilterRequestConfig>

    </cs:Config>

這裏轉向的是手機營業廳的配置,其中http頭中帶手機號碼x-up-calling-line-id

 

四、 終端適配

登錄DBU

clt -r contentadaptation

contentadaptation.xml;

不需要終端適配的url添加到如下地方

if(HttpReq.hostMatch("unisk.wap.wo.com.cn") ||HttpReq.hostMatch("tom.wap.wo.com.cn") ||HttpReq.hostMatch("qh.2g.wo.com.cn")……)

        {

                isenable="disable";

        }

其他默認都是進行終端適配的。

return isenable;

 

五、 增加重定向

例如:訪問*.tt560.com和wap.tusss.net重定向到www.wo.com.cn

登錄DBU

clt -r authorization

  <![CDATA[

  msid msisdn = Auth.getMsisdn ();

  msidrange barredRange = Msid.createRange("861*");

  string urlToRedirect ="wap.tt560.com";

  stringurlRedirected="http://www.wo.com.cn";

  if ( Msid.rangeContains (barredRange, msisdn)&& (HttpReq.hostMatch("*.tt560.com") || HttpReq.hostMatch ("wap.tusss.net")))

   {

            Mem.setConfigParams ( urlRedirected);

      return "redirect";

   }

  ]]>

需要重定向的url追加到紅色字體部分

 

首次瀏覽重定向

     <![CDATA[

       if(Session.getStr("FirstTime") == "") {

                    Session.putStr("FirstTime", "99");

                    Mem.setConfigParams("http://www.wo.com.cn");

                     return "redirect";

                }

     ]]>

 

 六、 訪問控制

web網關可以針對手機號段和具體手機號碼,訪問網站進行限制或允許訪問。

 

clt -r authorization

 

1.        針對手機號段和訪問域名進行限制訪問的配置,如156號段禁止訪問baidugoogle網站:

<! [CDATA [

 msid msisdn = Auth.getMsisdn ();

 msidrange barredRange = Msid.createRange ("86156*");

 string barredUrl = "www.google.com";

  if (Msid.rangeContains (barredRange, msisdn) && (HttpReq.hostMatch("www.baidu.com")|| HttpReq.hostMatch("www.google.com")))

    {

      return "deny";

    }

  else

    {

     return "allow";

    }

]]>

 

2.        涉黃網站封堵,將禁止訪問的域名追加在以下列表後邊:

<! [CDATA [

  stringset denyUrls = Str.createSetIgnoreCase(

"*.1234vv.com",

"*.172tp.cn",

"*.17cr.cn",

"*.18nrse.cn",

"*.258sl.cn",

………………

 

url放在下邊

stringset longUrls =Str.createSetIgnoreCase(

"http://www.google.cn/gwt/x/i?client=ms-tencent_cmcc-cn&ei=cdQNS5yXLpjq6AP5qqzhBw&output=wml&u=http%3A%2F%2Fimages.sxx.com/pic_teasers/1/15/1575/92f3d9191f/nude/01/1575_04.jpg&wsc=ti&wsi=1f5e4305249289c7",

"http://wap.sohu.com/book/paihang/?pg=BKREVIEW&nid=928&stid=dv&bkid=86758&cpid=48&t=93975",

"http://wap.baidu.com/s?word=%E4%B9%B1%E4%BC%A6%E6%BF%80%E6%83%85%E6%80%A7%E4%BA%A4&pn=10&rn=5&tn=webmain&from=140a_w1_1258388821&ssid=0&bd_page_type=0&prest=111001&st=111181&tt=22322&uid=index_124&pu=pd%402%2Cuc%400",

"http://gamexg.com/Book-readchapter-2445-712949-1-10000.html",

"http://news.wap.sohu.com/sogou/webs/?pg=webz&url=http%3A%2F%2Fz.easou.com%2Fshow.m%3Fpn%3D2%26amp%3Ba%3D0%26amp%3Bq%3D55niu.com%26amp%3Bsr%3Dhttp%253A%252F%252Fa.44b4.com%252Fhtml%252Fdushijiqing%252F1013313U2009.html%26amp%3Bsurl%3D%26amp%3Besid%3Dr2A-YFaj4zHWZ",

"http://3g.sina.com.cn/prog/wapsite/books/vipc.php?bid=99452&cid=62754&pn=3&isc=n&pcn=0&fix=0&vt=1&PHPSESSID=960342f0b4ff3171de805eec57f509e4&wm=4007",

"http://news.wap.sohu.com/pim/message/fmsglist.do?&u_uid=330544100_137d87dc&fr=uc001",

"http://hti.wap.wo.com.cn/3g/20/3GJ.wap",

"http://hti.wap.wo.com.cn/3g/20/3GO.wap",

"http://hti.wap.wo.com.cn/3g/20/3GI.wap",

"http://hti.wap.wo.com.cn/3g/20/3GC.wap",

……………..

]]>

3.        針對具體手機號和訪問域名進行限制訪問的配置,如手機號18609716448禁止訪問baidugoogle網站。

<![CDATA[

 msid msisdn = Auth.getMsisdn ();

 msidset barredRange1 = Msid.createSet("8618609716448");

   if (Msid.setContains(barredRange1,msisdn) && (HttpReq.hostMatch("www.baidu.com") || HttpReq.hostMatch("www.google.com")))

     {

       return "deny";

      }

   else

      return "allow";

]]>

 

 七、 圖片壓縮比配置

clt -r compression

ImageQualityReductionLevel="70"配置壓縮率

 

 八、 push配置

clt -r push

<Itemname="COMM_BEARER_1_TYPE" value="SMPP"/>

<Itemname="COMM_BEARER_1_WDP_SMS_DRIVER_SMSC_HOST" value="10.184.73.10"/>

<Itemname="COMM_BEARER_1_WDP_SMS_DRIVER_SMSC_PORT" value="8801"/>

<Itemname="COMM_BEARER_1_WDP_SMS_DRIVER_LOCAL_ADDRESS" value=" 1065578444/1065578444@1065578444"/>

 

  1. 10.184.73.10爲短信網關(sgip/短信中心(smpp)的IP地址,8801爲其端口。
  2. 1065578444/1065578444爲短信網關/中心提供給我們的用戶名,密碼
  3. 1065578444SP接入號,也是短信方需要提供的

 

 

 

APP配置文件:/etc/nbg/system/setup/cluster/cluster_setup.xml

<Application>

<ServiceName="Management"/>

<ServiceName="Radius"/>

<ServiceName="AccountingIf"/>

<ServiceName="Traffic"/>

<Service Name="Push"/>

</Application>

 

<Application>

<ServiceName="Traffic"/>

<ServiceName="Radius"/>

<ServiceName="AccountingIf"/>

<Service Name="Push"/>

</Application>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章