找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 1940|回复: 10

[TouchPad] pre 使用代理的方法, cmwap或许也能用了

[复制链接]
发表于 2011-9-19 21:00 | 显示全部楼层 |阅读模式
本帖最后由 mycccc 于 2011-9-19 21:01 编辑
" ]9 i6 ]+ J! a3 j7 n0 n# a2 }7 L9 _

# l, u5 M. p. ~! Q4 r! D9 E$ }
& N4 M+ @+ P3 w% ~
pre支持代理的现成软件估计是等不到了
8 Z6 Y4 E5 _* S% k5 M' f  L哪怕只是浏览器里加个代理选项,1.4.5没有,2.1也没有; ~/ ?3 w9 _; y
(或者webos有proxy软件么?我找了两天没找到)
& p+ ?; |9 a% q3 u- a3 M5 \8 j
1 N  B9 v! ]: f/ H
& A0 m5 |, Q( S- h1 m& r  X  z
搜了半天英文方面的资料,还真有
) s8 g% M# q6 ?* V, P发现在webos上代理实在是太linux了
8 w7 P0 u$ A# u) }
4 _1 E% z, @2 ]
3 H/ _( ?( n" R
方法如下:* y2 A" g  ]2 P/ X; ~
安装squid代理,添加一个节点代理,配置iptables的所有HTTP请求转发代理 。对浏览器等来说透明,这样就可以让不支持代理的各软件都通过代理
) |6 ?4 D1 ?3 r

4 f/ _- p& Y  i+ U+ ]8 w8 f1 A9 s9 u( a  x/ L
# _" N$ s0 }- Z4 f6 y7 `

, v) ~0 A* o+ v9 d8 s3 U
9 h/ g4 v: {$ f0 o0 e3 \  i! E( R$ p
按照这种方式
# H/ n* A0 N  P- o2 l2 H' {cmwap应该也可以设置成代理访问的
$ `( }1 _; l2 K8 d  G6 V这下无限流量的cmwaper们该笑了
- Z8 B$ M7 c$ G* y6 n7 J5 l" Z2 V' |; `  A$ p. J

+ _: B6 k% a# m, ]  i/ \* [ 原文见这里: http://www.daemon.de/PalmPreHowtoSquid
4 j  O7 v5 z& u' W+ D
& L$ `# n$ p3 g: j# s1 x- e

2 d3 J* m& r  d( M
Transparent Proxy on the palm pre for internet filtering and proxy forwarding
Ok, someone asked for it, so I figured it out, how to do it for fun and profit.
    Transparent Proxy on the palm pre for internet filtering and proxy forwarding
5 T2 {+ i7 p% M1 E: @$ g        Installing Squid
! c+ p  s+ h$ l' K  o0 {/ h        Create a basic proxy config) _/ k( o8 D6 V+ v  z
        Prepare the directories for squid
7 J# Y" P, S* ?. j7 c' [1 y+ ?        Starting squid% W) T/ n, T: Q  B. m8 n. m
        Redirect Web Traffic to the Proxy
* i; Y9 a" K( Y8 ^8 |% {5 b        Add the rules to the squid startup file8 ~' F9 c$ v" f& i# A; H: r3 f( G
        Configure network to startup squid if WLAN comes up:: i  \6 A3 W$ ]4 e9 T7 }
        See it working7 t' ?& q) x$ L* j% y, H: W
6 D4 \' \% N/ u! g& y! H
Installing Squid
First, you need to have root access to your device. How to get root, is described elsewere in this wiki. It would be a good idea to know a little about linux and networking too. Be warned: this can make your networking unfunctional!
Make your root disk writable:
cd / && mount -v -o remount,rw /
Login to the pre console and type this command to install the squid optware package
root@palm-webos-device: # ipkg-opt update ... root@palm-webos-device: # ipkg-opt install squid Installing squid (2.6.21-2) to root... Downloading http://ipkg.nslu2-linux.org/feed ... id_2.6.21-2_arm.ipk Configuring squid create default cache and logs dir chown: unknown user/group nobody:nobody chown: unknown user/group nobody:nobody FATAL: Could not determine fully qualified hostname.Please set  'visible_hostname'  Squid Cache (Version 2.6.STABLE21): Terminated abnormally. CPU Usage: 0.020 seconds = 0.010 user + 0.010 sys Maximum Resident Size: 0 KB Page faults with physical i/o: 0 Segmentation fault
You should review the configuration file /opt/etc/squid/squid.conf, make any necessary change, and complete the install by running -
/opt/etc/init.d/S80squid start  Successfully terminated.
Ignore the errors for the moment, we'll get to it soon.
Create a basic proxy config
Change to the directory /opt/etc/squid and move the file squid.conf which is already there to somewhere else. Now create a new squid.conf, which should have the following contents:
visible_hostname localhosthttp_port 3128 transparent                 hierarchy_stoplist cgi-bin ?               access_log /var/cache/squid/squid.log squid          acl QUERY urlpath_regex cgi-bin \?                   cache deny QUERY # replace the ip address with the address of your proxy# replace the port 3128 with the port of your proxycache_peer 192.168.2.205 parent 3128 3130 default # if your proxy requires authentication, use this:# cache_peer 192.168.2.205 parent 3128 3130 default login USERNAME PASSWORDrefresh_pattern ^ftp:           1440    20%     10080refresh_pattern ^gopher:        1440    0%      1440refresh_pattern .               0       20%     4320acl apache rep_header Server ^Apache                broken_vary_encoding allow apache    coredump_dir /var/cache/squid        cache_dir ufs /var/cache/squid 20 5 5access_log /var/cache/squid/squid.logcache_log /var/cache/squid/cache.logcache_store_log /dev/null acl all src 0.0.0.0/0.0.0.0acl manager proto cache_objectacl localhost src 127.0.0.1/255.255.255.255acl to_localhost dst 127.0.0.0/8acl SSL_ports port 443acl Safe_ports port 80          # httpacl Safe_ports port 21          # ftpacl Safe_ports port 443         # httpsacl Safe_ports port 70          # gopheracl Safe_ports port 210         # waisacl Safe_ports port 1025-65535  # unregistered portsacl Safe_ports port 280         # http-mgmtacl Safe_ports port 488         # gss-httpacl Safe_ports port 591         # filemakeracl Safe_ports port 777         # multiling httpacl CONNECT method CONNECThttp_access allow manager localhosthttp_access deny managerhttp_access deny !Safe_portshttp_access deny CONNECT !SSL_ports# example for an ACL, uncomment and modify#acl enemy dstdomain www.apple.com#http_access deny enemy http_access allow allicp_access allow all
Basicly this is a config for a transparent proxy, thus a browser will be redirected to it without knowing that it is actually connected to a proxy. We must configure it this way because the WebOS browser cannot be configured to use a proxy.
Note that we have added a single ACL here, which denies access to some random site *g*. Any other requests will be allowed. SSL (HTTPS) will not be passed through the proxy because this requires the browser to connect to it using a proxy request.
Prepare the directories for squid
Squid needs a directory where to store it's files, as content it caches and logfiles. You may consider to disable caching and logging. But caching may be a good idea if your traffic is limited, so you'll save some. Logging is always usefull for debugging. If you want to turn it off, use /dev/null as target for the logfiles.
mkdir /var/cache/squid chown nobody /var/cache/squid
Next you need let squid to prepare the directory structure using the -z option:
root@palm-webos-device: # squid -z -f squid.conf 2009/11/26 23:19:29| Creating Swap Directories
You should not see any errors here!
Starting squid
The installer already added it to the startup daemons, now we will start it manually:
/opt/etc/init.d/S80squid start
Look in /var/cache/squid/cache.log for any errors. Use ps to see if it really runs. You may consider to install lynx and test the proxy:
ipkg-opt install lynx export http_proxy=http://localhost:3128 lynx www.google.com
If you see a google textmode site, it works.
Redirect Web Traffic to the Proxy
Now comes the ugly part. I'll not explain it in detail: we install some iptable Rules. We tell iptables to forward any traffic destined to tcp port 80 to localhost port 3128 (this is where squid listens for incoming connections). To avoid that the requests of the proxy itself are forwarded to localhost (which would create a loop), we add a rule telling iptables to not forward web traffic if it were generated by user nobody (the user squid runs as):
iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --gid-owner 65534 -j ACCEPT iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:3128
You should not get any response from iptables. Let's see if the rules were added correctly:
root@palm-webos-device: # iptables -nL -t natChain PREROUTING (policy ACCEPT)target     prot opt source               destination          Chain POSTROUTING (policy ACCEPT)target     prot opt source               destination          Chain OUTPUT (policy ACCEPT)target     prot opt source               destination         ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80 owner GID match65534 DNAT       tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80 to:127.0.0.1:3128 Add the rules to the squid startup file
Edit /opt/etc/init.d/S80squid so that it looks like this:
#! /bin/shcase "$1" in    start)        echo -n "Starting proxy server: "        if [ -n "`pidof quotacheck`" ]; then           #you don't need it if you don't have quota check enable.           echo "Starting squid-cache server after delay for few mins:"           /opt/etc/squid/squid.delay-start.sh&        else           /opt/sbin/squid -f /opt/etc/squid/squid.conf           iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --gid-owner 65534 -j ACCEPT           iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:3128           echo "done."        fi        echo "done."        ;;    stop)        echo -n "Stopping proxy server: "        /opt/sbin/squid -f /opt/etc/squid/squid.conf -k shutdown        iptables -t nat -D OUTPUT -p tcp --dport 80 -m owner --gid-owner 65534 -j ACCEPT        iptables -t nat -D OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:3128        echo "done."        ;;    reload|force-reload)        echo -n "Reloading proxy server configuration files: "        /opt/sbin/squid -f /opt/etc/squid/squid.conf -k reconfigure        echo "done."        ;;    restart)        echo -n "Restarting proxy server: "        /opt/sbin/squid -f /opt/etc/squid/squid.conf -k shutdown        sleep 2        /opt/sbin/squid -f /opt/etc/squid/squid.conf        echo "done."        ;;    *)        echo "Usage: /opt/etc/init.d/S80squid {start|stop|reload|force-reload|restart}"        exit 1        ;;esac Configure network to startup squid if WLAN comes up:
Change to directory /etc/pmnetconfig/.
In the file if-up modify this part:
if [ "$ISPPP" -ne 4 ] && [ "$ISRMNET" -ne 6 ] && [ "$ISTUN" -ne 4 ] && [ "$ISCSCOTUNVPN" -ne 8 ]; then    NetCfgSetAddr    CMSERVICES=$((${CMSERVICES} | ${CMSVCINTERNET})) fi
to
if [ "$ISPPP" -ne 4 ] && [ "$ISRMNET" -ne 6 ] && [ "$ISTUN" -ne 4 ] && [ "$ISCSCOTUNVPN" -ne 8 ]; then    NetCfgSetAddr    CMSERVICES=$((${CMSERVICES} | ${CMSVCINTERNET}))    /usr/bin/logger "wifi up: execute /opt/etc/init.d/S80squid start"     /opt/etc/init.d/S80squid start fi
In the file if-down modify this part:
if [ ${CMINTERFACE} = ${CMBTINTERFACENAME} ] || [ ${CMINTERFACE} = ${CMBRINTERFACENAME} ]; then    ${LOG} "${IPTABLES} -t nat -D POSTROUTING -s  $CMNETADDR/$CMPREFIXLEN -j MASQUERADE"    ${IPTABLES} -t nat -D POSTROUTING -s $CMNETADDR/$CMPREFIXLEN -j MASQUERADE    ${LOG} "${ECHO} 0 >/proc/sys/net/ipv4/ip_forward"    ${ECHO} 0 >/proc/sys/net/ipv4/ip_forward fi
to:
if [ ${CMINTERFACE} = ${CMBTINTERFACENAME} ] || [ ${CMINTERFACE} = ${CMBRINTERFACENAME} ]; then    ${LOG} "${IPTABLES} -t nat -D POSTROUTING -s  $CMNETADDR/$CMPREFIXLEN -j MASQUERADE"    ${IPTABLES} -t nat -D POSTROUTING -s $CMNETADDR/$CMPREFIXLEN -j MASQUERADE    ${LOG} "${ECHO} 0 >/proc/sys/net/ipv4/ip_forward"    ${ECHO} 0 >/proc/sys/net/ipv4/ip_forward    /usr/bin/logger "wifi up: execute /opt/etc/init.d/S80squid stop"         /opt/etc/init.d/S80squid stop          fi See it working
So, let's see how it works. Enable WIFI and fire up the browser and see if it works. You should see your requests on the remote proxy.
If you added an ACL as mentioned earlier, a message like the following should appear if you enter the url of your favourite enemy vendor (the one we configured above):
If it doesn't work, check /var/log/messages and look for "squid"! /var/cache/squid/cache.log is also a good place to look for failures. Good luck!
6 Z" r$ P( m1 E0 O4 ]

  t5 c" ?8 {8 V( w

评分

参与人数 1威望 +5 收起 理由
寂夜清风 + 5 谢谢分享

查看全部评分

回复

使用道具 举报

 楼主| 发表于 2011-9-19 21:02 | 显示全部楼层

9 r  ]8 c1 f; Z2 v/ D) ]" Adiscuz这排版弄得
6 k3 A) E# L8 i3 }) ]+ t大家看原文
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-9-19 21:03 | 显示全部楼层
SetupSquidTransparentProxy; B. C* o$ x( F: N/ j

- z! x: z7 I4 V0 ISquid Transparent Proxy on Palm Pre
: j# J5 U1 q7 T& q0 U1 ?# z0 H( [6 u, m7 a
Ok, someone asked for it, so I figured it out, how to do it for fun and profit:1 ~1 o$ u; p0 F: l+ P

+ T& T9 T& [0 [, bHide Preparation' I0 V2 B/ n1 K: F
. I! y# l: \. M
First, you need to have root access to your device. How to get root, is described here. It would be a good idea to know a little about linux and networking too. Be warned: this can make your networking unfunctional!
$ l( F. h  y7 G0 ?
6 y4 c  X3 {  \' {Next thing you need to do is to install the package Optware Advanced Linux Command Line Installer from Preware, which installs ipkg-opt!
) t- @7 X7 D8 f; A7 L. S( @' i! m3 T# ]2 E7 E* E+ _
↑ Jump Back A Section
% {/ M4 {) Z. l% F9 C! q' XHide Installing Squid
. ^0 i# J* M8 g" C
1 @5 i( g8 F7 lLogin to the pre console and make your root disk writable:
1 T& o1 l+ E, J
8 N: d9 j- q4 s% Sroot@palm-webos-device: # cd / && mount -v -o remount,rw /9 t; d" d! i  ~! Y
Type this command to install the squid optware package
0 T  N) ~. ?9 U% u, l6 J5 k
' o( o( C2 y% H1 ]0 J# ~  ^5 Proot@palm-webos-device: # ipkg-opt update
; y8 ]$ ?% r) a( D7 N; S% g3 R      ...
4 C! ^0 C  b- }) Y$ h      root@palm-webos-device: # ipkg-opt install squid
. V, t0 u2 M3 Q3 u- r      Installing squid (2.6.21-2) to root...- h. T4 R( a9 @* F
      Downloading http://ipkg.nslu2-linux.org/feed ... id_2.6.21-2_arm.ipk
/ q. m3 l) t1 d7 _! U      Configuring squid
& n+ y3 `2 }. s$ `. R* m8 i      create default cache and logs dir1 q& O. s" E: P; H9 T% v- f
      chown: unknown user/group nobody:nobody
9 F$ w& g  V8 b7 ~" p      chown: unknown user/group nobody:nobody( [; M6 N( O; Y
      FATAL: Could not determine fully qualified hostname.Please set 'visible_hostname'& {# \5 D% P' R
      
+ h/ @2 z* y/ u& `      Squid Cache (Version 2.6.STABLE21): Terminated abnormally.
7 ?9 k+ h7 }" h      CPU Usage: 0.020 seconds = 0.010 user + 0.010 sys
( i2 n4 n2 o! G3 s6 U( P4 U5 }      Maximum Resident Size: 0 KB9 b3 _6 p6 W0 @! ]  {* ]/ e
      Page faults with physical i/o: 00 }3 j" u0 M2 L" z
      Segmentation fault
- d+ R0 G# o& Z" U: X       7 \, l+ e3 `) }! s3 _
      You should review the configuration file /opt/etc/squid/squid.conf,
( C; `5 K' ]6 a! l      make any necessary change, and complete the install by running -
! M7 c" |9 B; I4 E  ]5 l3 k: B      /opt/etc/init.d/S80squid start
; q9 `) N% I1 a  y! G4 m0 ]# B1 ]       ! h8 _6 m- a* n/ G  S
      Successfully terminated.
4 p1 d5 o; i; J3 X/ {( w' Z* CIgnore the errors for the moment, we'll get to it soon.
  m- ]5 U8 L4 x0 K- Z. j' M7 y* _3 @! x- P4 }2 ~1 }* @
↑ Jump Back A Section
4 }9 |% }# ?" P* x6 x1 a6 IHide Create a basic proxy config
+ G& G  s- N- c
  O8 q( p, a8 V6 p9 z! lChange to the directory /opt/etc/squid and move the file squid.conf which is already there to somewhere else. Now create a new squid.conf, which should have the following contents:
$ n1 B) S2 ?7 b. [5 r" W. ~: |& n& r) ^4 X
visible_hostname localhost
% K6 }) X) s( f6 @      http_port 3128 transparent                 3 |- f8 @3 }- N
      hierarchy_stoplist cgi-bin ?               
1 P' s" x( z( Z) }; M4 q% l      access_log /var/cache/squid/squid.log squid         
: x0 I. e: K. J: s# K$ a      acl QUERY urlpath_regex cgi-bin \?                  
- z- m: u! d& K1 i2 w9 F$ P. l8 [      cache deny QUERY * f! ?% J. a, f8 z
       3 S( o. P: J$ \! W
      # replace the ip address with the address of your proxy9 B8 a" z& S, K& O5 l
      # replace the port 3128 with the port of your proxy# r! n9 M1 o0 {7 L4 t
      cache_peer 192.168.2.205 parent 3128 3130 default $ r7 H) n% v0 ?5 }, ~' _( r; t
       : R, o* O1 P: z5 r: W2 w0 a8 P; C7 ]
      # if your proxy requires authentication, use this:. V8 @% Y4 u% o( L
      # cache_peer 192.168.2.205 parent 3128 3130 default login USERNAME PASSWORD6 U% D( d0 P$ z4 ^, M0 l
       1 u) a+ r$ G6 J& C
      refresh_pattern ^ftp:           1440    20%     10080
9 t  M+ y, S, ~      refresh_pattern ^gopher:        1440    0%      1440, E6 f# I- E. X0 k* I1 \, }) [! y
      refresh_pattern .               0       20%     43205 o9 k4 `2 H5 ]( R) l
      acl apache rep_header Server ^Apache                & \2 j6 }6 D. o
      broken_vary_encoding allow apache   
4 H) E- |9 @( Y      coredump_dir /var/cache/squid        
& r0 q1 @# }; v: v      cache_dir ufs /var/cache/squid 20 5 5- I5 j' c& Z- E9 J4 d
      access_log /var/cache/squid/squid.log8 h2 I3 X- |8 v+ N
      cache_log /var/cache/squid/cache.log
, a# b( _5 K2 F* S      cache_store_log /dev/null- y, s0 `7 B  T* v$ s& B/ r
       ; Z# l5 B) N& h6 J' ^- `  N1 U" _
      acl all src 0.0.0.0/0.0.0.0% A: w% a  i/ z9 A  }5 H6 ?! R
      acl manager proto cache_object
9 ~; P4 Z7 h' |/ C6 v; D) ]      acl localhost src 127.0.0.1/255.255.255.255
- p* {3 P( R3 s# d# N& i      acl to_localhost dst 127.0.0.0/8
. \2 x0 F' d) m2 G      acl SSL_ports port 443
% m6 t3 B  z4 E& w! z% F6 G7 R( ^/ G      acl Safe_ports port 80          # http
8 w3 A& d8 r/ Q, l, i8 C      acl Safe_ports port 21          # ftp
# ]0 U0 X6 J" E& E1 B      acl Safe_ports port 443         # https
1 Y: d6 n6 C- s3 r! w" K* T& A      acl Safe_ports port 70          # gopher8 C9 [- Z- l2 e+ I; _3 U
      acl Safe_ports port 210         # wais
1 H0 z9 Y; m! \" h. T      acl Safe_ports port 1025-65535  # unregistered ports
3 W0 R# V- Z' j2 i      acl Safe_ports port 280         # http-mgmt8 l& ]" p1 \- @8 T% Q
      acl Safe_ports port 488         # gss-http, X1 y, g! N" T" ?+ b
      acl Safe_ports port 591         # filemaker$ X8 Z* b4 k: a# f* f2 F
      acl Safe_ports port 777         # multiling http
( b' s! H7 O& q; X      acl CONNECT method CONNECT; b$ T; a, e# W  \" D6 f0 K% |# K
      http_access allow manager localhost
/ `$ w  S1 U0 p0 T/ S      http_access deny manager9 @: n& P7 c6 g. U9 p% ]
      http_access deny !Safe_ports1 b/ N: X- i% S0 H( I, V& ^
      http_access deny CONNECT !SSL_ports( l8 y5 Q( o( @7 ]* x% r/ o
      # example for an ACL, uncomment and modify  g) G, U/ M3 W9 Q" A
      #acl enemy dstdomain www.apple.com6 E0 G9 J8 r, D( w) C1 T
      #http_access deny enemy
/ d: w- k) I2 v9 p       2 B2 ?% B9 t: f3 i, \* U
      http_access allow all
5 s! x+ p5 F; x5 G( f, x      icp_access allow all4 h% L2 x4 A7 H4 Z* T, u
Basically this is a config for a transparent proxy, thus a browser will be redirected to it without knowing that it is actually connected to a proxy. We must configure it this way because the WebOS browser cannot be configured to use a proxy.
  E4 J% `7 r! Q5 z* @5 s0 Y8 c5 ]" M5 a1 I" m$ K  A4 v0 W. i
Note that we have added a single ACL here, which denies access to some random site *g*. Any other requests will be allowed. SSL (HTTPS) will not be passed through the proxy because this requires the browser to connect to it using a proxy request.% M/ W9 D7 L  [0 B( m+ J8 b
2 d) ]+ T6 D) u2 H. F
You WILL need to modify the squid.conf variable cache_peer, it points to your upstream proxy, e.g. your companys proxy. Refer to the comments for the syntax.
" F" _0 D; _" l  ]  j+ {& e6 p
6 E: t; N) i- `5 e  s4 E↑ Jump Back A Section
# J8 ]( `6 ?. O' g# S* [6 @* uHide Prepare the directories for squid
1 |. f# v0 B. U; ?2 g0 C7 ~) j# F7 {% D
Squid needs a directory where to store it's files, as content it caches and logfiles. You may consider to disable caching and logging. But caching may be a good idea if your traffic is limited, so you'll save some. Logging is always usefull for debugging. If you want to turn it off, use /dev/null as target for the logfiles.9 I7 Z" g9 V4 j5 N. m
9 h( s) |) d* _/ t6 N- A2 @
mkdir /var/cache/squid
5 v8 R: N: c) s' M2 K- e! ~  w      chown nobody /var/cache/squid
; e7 k2 u, M4 K9 q, tNext you need let squid to prepare the directory structure using the -z option:
* C5 `0 }! u5 l. \& t9 _" d' C, i0 n0 h* N+ @( p) L
root@palm-webos-device: # squid -z -f squid.conf
4 k6 c: t4 r, W      2009/11/26 23:19:29| Creating Swap Directories
6 h3 r. R6 c6 v$ |" j+ }7 VYou should not see any errors here!
2 H. j2 N( g! V: v; b
% D) l3 T0 D* u: F2 R↑ Jump Back A Section
3 m  A0 A  |& x  X8 D! h) N" aHide Starting squid* |! t# v7 U( {) N4 h9 P
0 [- J- ~6 v; |
The installer already added it to the startup daemons, now we will start it manually:) N# T2 `4 w1 x2 X# j& i
8 R* |" L3 N; p/ T/ e  e
/opt/etc/init.d/S80squid start" J" X) G$ y1 Q* M
Look in /var/cache/squid/cache.log for any errors. Use ps to see if it really runs. You may consider to install lynx and test the proxy:
4 H2 S! N2 F: x$ M; q7 P( w4 @
* o/ u; P$ F1 E' e' H2 v( gipkg-opt install lynx; d# D& G' e* t& N9 A2 Q+ q, i
      export http_proxy=http://localhost:3128
2 O: l# @# K# A% N2 C; {      lynx www.google.com
+ H# u- u$ Y$ U; w- g; l# s) FIf you see a google textmode site, it works.* h; c9 h0 b- g" X! W; l

$ W( m. O# n  `& N5 r& ~Turn it off if everything is ok:: C0 `7 Q( X8 z! U" j+ C0 M4 d! M

& a: l3 T  s! X/opt/etc/init.d/S80squid stop7 G4 j, o/ A" z
↑ Jump Back A Section
2 h1 g7 @6 N2 B* QHide Add the rules to the squid startup file
2 A# ?! G: U: o/ l
- L; M, s& x' P  E! @Now comes the ugly part. I'll not explain it in detail: we install some iptable Rules. We tell iptables to forward any traffic destined to tcp port 80 to localhost port 3128 (this is where squid listens for incoming connections). To avoid that the requests of the proxy itself are forwarded to localhost (which would create a loop), we add a rule telling iptables to not forward web traffic if it were generated by user nobody (the user squid runs as).
; M5 B, t7 @2 X& w
4 z; Z. y/ k: s% rTo do that, edit /opt/etc/init.d/S80squid so that it looks like this:2 T- V* x. ]0 `* l% i8 G, O6 ~

9 Q. A6 n7 S$ |* m  O  p1 G#! /bin/sh' F# @. R! ~5 b/ E5 c
      
7 i2 ^: a1 K" B/ L; b5 c' W$ q$ @      case "$1" in
8 g. Y) [) E7 ~          start)/ V5 t9 z" n( l: @* }; E
              echo -n "Starting proxy server: "
& h  b- v8 l1 H              if [ -n "`pidof quotacheck`" ]; then
+ H$ L2 b6 c& D+ x+ V: O& s                 #you don't need it if you don't have quota check enable.
7 c1 E% ?3 t- a: r9 m- I6 O' Y                 echo "Starting squid-cache server after delay for few mins:"7 r' t3 Y: I6 D/ B8 z
                 /opt/etc/squid/squid.delay-start.sh&
& C$ ^( w# V( J& O; L4 c              else, l; P; |# [& S- F: L
                 /opt/sbin/squid -f /opt/etc/squid/squid.conf4 Q5 J# V2 O0 e6 p  z- V) s
                 iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --gid-owner 65534 -j ACCEPT
3 l0 r8 g( O) R8 I                 iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:3128/ f. X* W0 v/ z; f! }! t: y8 Z, _8 f
                 echo "done."* }) G- \9 a: v& c, u5 K
              fi) _5 }, K& k; J& r# m
              echo "done."0 t; r9 H+ R! y% E% V4 U2 L
              ;;1 I. S# Y  V1 T4 t7 u' X
          stop)1 U5 J' d6 }5 x* t7 ?4 e
              echo -n "Stopping proxy server: ") ?# I7 _3 T- @0 a% h
              /opt/sbin/squid -f /opt/etc/squid/squid.conf -k shutdown
& o/ `+ T2 B  T4 G              iptables -t nat -D OUTPUT -p tcp --dport 80 -m owner --gid-owner 65534 -j ACCEPT; [6 ]6 J9 y. W- l. H& ]" y1 V
              iptables -t nat -D OUTPUT -p tcp --dport 80 -j DNAT --to-destination 127.0.0.1:3128
' s: Q6 y) @, u' E, R              echo "done."
5 F1 T+ M+ h4 T) L- I5 C% J* E              ;;
: h$ H9 K; Y9 ^          reload|force-reload)$ B2 F$ X( e  O1 Z1 [9 f
              echo -n "Reloading proxy server configuration files: ") E3 A) ^  Q; Y+ d- F9 m( _" u
              /opt/sbin/squid -f /opt/etc/squid/squid.conf -k reconfigure4 p1 y1 E( F6 y' W
              echo "done."
! b2 V, _( @# q* u- C: j              ;;
$ C. E6 {3 P* |$ s5 k8 }          restart)
! @1 [0 N6 K6 i2 L              echo -n "Restarting proxy server: ". O4 e; r3 i- C8 V' S7 Z
              /opt/sbin/squid -f /opt/etc/squid/squid.conf -k shutdown
1 I8 V* O: _0 G$ L  x              sleep 2' c8 P- s  o/ \; M  \
              /opt/sbin/squid -f /opt/etc/squid/squid.conf
7 ?1 _4 i. V% n/ _              echo "done."  [9 M6 O" e; [$ V) G+ ~5 D" G
              ;;
+ s/ X, P9 D' u4 s, v3 M          *)' o- Z" }$ O4 H; \! L
              echo "Usage: /opt/etc/init.d/S80squid {start|stop|reload|force-reload|restart}"
& x' \  ~# `' X0 j5 E) }/ j              exit 1
; C9 z% T& b. s& P              ;;
' }% K4 |* U5 s7 h      esac- \! f& s+ B" a4 i
↑ Jump Back A Section
4 d2 c0 `" P& s9 {- t3 UHide Configure network to startup squid if WIFI comes up5 i* c7 n! T* G: G- `
! K6 ~- t/ Q1 }7 Z
Now we need to alter the behavior of the palm network manager so that it starts squid if WIFI comes up and stops it when WIFI goes down.
4 H# c7 o3 D/ G2 d+ i: ^7 U% B* S3 W- p. Z
Change to directory /etc/pmnetconfig/.
. |1 a, S6 j9 n, ?: |% e/ C$ z  _8 ]8 S0 m# j$ I; f3 A* ~; l: b
In the file if-up modify this part:8 c5 O3 r3 l0 `' |3 J
( Y. Q: g  K/ ~2 o0 g
if [ "$ISPPP" -ne 4 ] && [ "$ISRMNET" -ne 6 ] && [ "$ISTUN" -ne 4 ] && [ "$ISCSCOTUNVPN" -ne 8 ]; then
8 K1 z6 D. f) w9 r- s' R          NetCfgSetAddr1 O' B( V& z2 J, `8 Q
          CMSERVICES=$((${CMSERVICES} | ${CMSVCINTERNET})); ?6 ~" k) M5 W; C6 u0 V8 `' t
       fi
2 Q4 ^& H# d$ g2 K0 U  oto
2 `+ s; a0 c2 O  h9 {! j0 G) D% l. s" N2 z1 \# H2 {3 c
if [ "$ISPPP" -ne 4 ] && [ "$ISRMNET" -ne 6 ] && [ "$ISTUN" -ne 4 ] && [ "$ISCSCOTUNVPN" -ne 8 ]; then3 Y$ Q' _* l/ w2 U9 |
          NetCfgSetAddr& d6 e# E4 z& X9 P% W/ ]
          CMSERVICES=$((${CMSERVICES} | ${CMSVCINTERNET}))
5 P8 z8 ^1 c/ J( h, ]# b& m) E          /usr/bin/logger "wifi up: execute /opt/etc/init.d/S80squid start"
* Y3 u) i; N- D, z' f9 Y          /opt/etc/init.d/S80squid start. J- r+ {9 p6 m) F+ P9 x" z- i) \# \- g
       fi
3 S: {9 m% ?, qIn the file if-down modify this part:
+ h- y8 s6 e- n8 m9 T- A
( M9 S. N  [* C0 f9 E. e if [ ${CMINTERFACE} = ${CMBTINTERFACENAME} ] || [ ${CMINTERFACE} = ${CMBRINTERFACENAME} ]; then
/ N. I; i9 p' J# X- I* X) p          ${LOG} "${IPTABLES} -t nat -D POSTROUTING -s  $CMNETADDR/$CMPREFIXLEN -j MASQUERADE"8 A, S& F" r9 p" b8 I
          ${IPTABLES} -t nat -D POSTROUTING -s $CMNETADDR/$CMPREFIXLEN -j MASQUERADE
' r% g' `# ]' C' E) G          ${LOG} "${ECHO} 0 >/proc/sys/net/ipv4/ip_forward"
  g% R. U, \0 C3 ~          ${ECHO} 0 >/proc/sys/net/ipv4/ip_forward% ?( |1 K' d" o% j2 v5 x9 m0 ]
       fi
" c9 C: U# ^' o8 m0 G% G+ Xto:
: F( B) ]- G# P9 T8 b/ @9 p- m' H8 `0 ]( @( x) l
if [ ${CMINTERFACE} = ${CMBTINTERFACENAME} ] || [ ${CMINTERFACE} = ${CMBRINTERFACENAME} ]; then
4 o: v5 g! t& o) O/ V/ _          ${LOG} "${IPTABLES} -t nat -D POSTROUTING -s  $CMNETADDR/$CMPREFIXLEN -j MASQUERADE"0 u8 c* Y/ m9 `9 s3 I* b) i- T
          ${IPTABLES} -t nat -D POSTROUTING -s $CMNETADDR/$CMPREFIXLEN -j MASQUERADE
. W1 I$ H6 |6 |8 N          ${LOG} "${ECHO} 0 >/proc/sys/net/ipv4/ip_forward"3 @" m. k9 N) X
          ${ECHO} 0 >/proc/sys/net/ipv4/ip_forward% T2 P# ~3 j/ C: V2 E
          /usr/bin/logger "wifi up: execute /opt/etc/init.d/S80squid stop"     ( p8 S2 N4 E8 x. {" }
          /opt/etc/init.d/S80squid stop         % w, J) l. D" ^7 V7 n
       fi
6 @& W  {6 p: F' S. I3 [; L↑ Jump Back A Section* }$ S: G4 h1 i5 ~: t( J+ B7 P
Hide Make your root disk read-only again' [8 h7 N1 J4 h3 m
& q5 I1 J6 r( R- c! m
root@palm-webos-device: # cd / && mount -v -o remount,ro /. a# c( ?3 q: B4 y
↑ Jump Back A Section& _; @( T# b6 Z& a/ D
Hide See it working
8 ]3 z/ Y4 S& {4 \- P  n5 t" m
; h% R5 H( @, r+ {, Q( k2 p$ O4 eSo, let's see how it works. Enable WIFI and fire up the browser and see if it works. You should see your requests on the remote proxy.8 \! }& z. u) b5 i, Z: m1 ~- c; L/ [
8 ]) r* N3 G' c
If you added an ACL as mentioned earlier, a message like the following should appear if you enter the url of your favourite enemy vendor (the one we configured above):
, \, w. F6 H: W* Q5 p
8 E) R3 _" k( S7 [% g% Y" Z! i5 v" B' ?

9 o" S7 o: C$ F! A9 f↑ Jump Back A Section
- }0 t; v. C$ L/ z( f, ~Hide Blocking Adverts1 {" ]  ~- {2 d
  ]+ T2 H5 s, M4 X6 D
Now squid is set up, we can use it for ad blocking. There are two steps to this:
: F# Q+ v; Q, N( B
( C3 D& ~! F0 z* A+ B3 tObtain a block list
- s; _5 X- n; G  p& o
$ z. H4 ~  v8 h: j( dAn excellent ad block list is maintained at http://pgl.yoyo.org/as/. We need to download it in a suitable format for squid, which can be done by running the following command:
$ _  n$ w6 _! b/ U! o& d7 H1 C! Y& Z1 ?- Y8 H: k- [
wget -q -O/opt/etc/squid/blocklist 'http://pgl.yoyo.org/as/serverlist.php?hostformat=squid-dstdom-regex;showintro=0&nohtml=true&mimetype=plaintext > /opt/etc/squid/blocklist3 w5 M( E+ G, p( d
(Technical details: the wget command downloads the URL given in single quotes, then we strip the HTML mark-up and blank lines using grep. The filename at the end is where the black list will be stored.)
6 g+ o; [" J* n' z  s* H, w5 W) \( l( D( |4 M& X- r4 e* z7 p
Configure squid to use the block list
6 H6 C* I- b: l" q8 A% q% @- j' |+ p# p/ |6 L0 }0 K
Now we need to tell squid to block the list of URLs in the file we've just created. Open the /opt/etc/squid/squid.conf file we created above, and scroll down to where it reads:& T' v5 d0 m5 a1 K* o

7 q2 ^5 M9 @0 N: lacl enemy dstdomain www.apple.com
( q" {% Q  i7 ~. v- u# Y7 _Replace this line with:# e) u3 {* a8 c4 O( h

2 v  T, Q2 ~# e4 [% c( Gacl enemy dstdom_regex "/opt/etc/squid/blocklist"
0 F: {: G( c( Y4 U8 k8 GFinally, restart squid:
" |- Z9 h% q! g1 `
. o3 }$ \1 F$ F6 H, w- r/opt/etc/init.d/S80squid restart
% B/ `3 z  e2 _+ ^, C  RTo test it's working, open a browser and try to visit ads.msn.com (one of the blocked URLs). The error given should be similar to the screenshot given above.
! h! I6 n! g# q" b, ^1 [6 I4 H+ m/ Z. a: m
If in the future you need to update the ad blocking list, run the commands:
" ?6 S. d4 F- K( B  G7 a0 T
, D, {" `4 l& ~" x: W6 ~cd / && mount -v -o remount,rw /- m% ]5 m/ k3 p2 x2 o
      wget -q -O - 'http://pgl.yoyo.org/as/serverlist.php?hostformat=squid-dstdom-regex;showintro=0'  | grep -v ">" | grep "." > /opt/etc/squid/blocklist, s. p4 r& j# |, k+ t1 O2 L$ I3 H$ v; ^
      /opt/etc/init.d/S80squid restart
( V, P2 K) W9 O( g  i, L1 }For further details of filtering URLs using squid, please refer to the excelent documentation of the squid cache project.
回复 支持 反对

使用道具 举报

发表于 2011-9-19 21:12 | 显示全部楼层
英文还给老师了  求大神  直接出方法5 Z) f0 d! _0 W8 r$ t& q
回复 支持 反对

使用道具 举报

发表于 2011-9-19 22:34 | 显示全部楼层
这里有跟详细参数 看下http://bbs.gfan.com/?fromuid=179411
回复 支持 反对

使用道具 举报

 楼主| 发表于 2011-9-20 12:53 来自手机 | 显示全部楼层
5楼骗链接
回复 支持 反对

使用道具 举报

发表于 2011-9-20 15:19 | 显示全部楼层
如果有td的模块就好了
5 F( x! l) j% p2 n
回复 支持 反对

使用道具 举报

发表于 2011-9-20 20:05 | 显示全部楼层
我现在在用prejvm+UC+qq,可以上网
回复 支持 反对

使用道具 举报

发表于 2011-9-21 15:58 | 显示全部楼层
这个教程有点难度~~~可以写的详细一些吗,就是把每一步做什么,需要安装什么,怎么设置仔细写出来,求大神给个图文并茂的帖子,相信cmwap包月吧不限流量的同学回顶礼膜拜的!
回复 支持 反对

使用道具 举报

发表于 2011-9-21 18:32 | 显示全部楼层
是啊,希望有哪位大大可以把步骤简化一下,期待cmwap可以用啊
4 Q" [# |1 @$ y: d# w5 K
回复 支持 反对

使用道具 举报

发表于 2011-9-28 22:06 | 显示全部楼层
这完全是跑了个linux小程序
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

QQ|Archiver|手机版|小黑屋|吹友吧 ( 京ICP备05078561号 )

GMT+8, 2024-7-5 05:37 , Processed in 0.359079 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表