本帖最后由 mycccc 于 2011-9-19 21:01 编辑 2 t$ U9 S/ m* m2 D% A! t5 ]
( x2 f8 b/ \' Z0 ~/ |4 X! T. X' p/ l$ N
# [. t. O5 D, ~3 ?
pre支持代理的现成软件估计是等不到了
, v) f% S0 j/ |4 R$ j哪怕只是浏览器里加个代理选项,1.4.5没有,2.1也没有
$ ~5 s1 _! _& c$ z, n5 _' m Y (或者webos有proxy软件么?我找了两天没找到)" E9 C$ T& ?# q( i2 ^5 D! `) L: v% ~" S9 t
+ _% G B) {1 L& {- W
7 N f1 V* ~% I, s0 `搜了半天英文方面的资料,还真有+ Z6 _5 y* A: U/ T ^* x
发现在webos上代理实在是太linux了
5 A, y+ Y4 X- J( i$ r3 w8 i6 A6 a- n' k2 P- d: N% q$ O8 [
. Q, A0 G' x4 a! l: J
方法如下:
/ X O7 A4 g* r* ~# ~- T: y安装squid代理,添加一个节点代理,配置iptables的所有HTTP请求转发代理 。对浏览器等来说透明,这样就可以让不支持代理的各软件都通过代理
% s; c" R. `6 g% \5 g
9 m% [/ W9 I& v* c3 n' p% p" P
w: Q. j/ M" E% _
7 Z- v1 H. |/ i* N, C2 ^% k/ Z: g
' E9 H- y+ Y! F5 ~
按照这种方式9 k& h. Z5 e; `6 N9 {
cmwap应该也可以设置成代理访问的
7 `. }8 H, j/ n3 ]这下无限流量的cmwaper们该笑了4 _& N2 e! |. i$ i
1 u1 M; ]4 N7 a$ M7 X
9 K( R& t) C9 P7 k4 [/ D7 M 原文见这里: http://www.daemon.de/PalmPreHowtoSquid. K7 k' O6 [1 `/ x; t: @, a
& x; }/ w8 V0 v$ j5 A
- G) H- J/ T# s% m; x' V4 |Transparent Proxy on the palm pre for internet filtering and proxy forwardingOk, someone asked for it, so I figured it out, how to do it for fun and profit.
% w, A, H* G4 c$ g* K: E$ VInstalling SquidFirst, 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 configChange 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 squidSquid 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 squidThe 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 ProxyNow 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 fileEdit /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 workingSo, 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 i. Z$ w# n B1 c
0 ]& E8 J/ h: [8 f
|