如何使用代理服务器

2010年1月17日 hashei 没有评论

转载自月光博客 [ http://www.williamlong.info/ ]
本文链接地址:http://www.williamlong.info/archives/2057.html

本文为个人收藏及技术传播

虽然我们的网络在公开场合下自称是“开放”的互联网,但实际情况却不是这样的,例如前几天,已经有两个同事咨询过我,如何使用代理服务访问Facebook,我发现其过程还是挺多的,与其我一步步讲给他们听,不如写一个教程,这样他们也更能理解和操作。下面我就介绍一下我是怎么使用代理服务器的,算是一篇科普教程吧。

前面一段是科普教程,如果你只关心如何使用代理,可以直接跳到“如何使用SOCKS代理服务器”这一段。

什么是代理服务器

代理服务器(Proxy Server)是网上提供转接功能的服务器,在一般情况下,我们使用网络浏览器直接去连接其他Internet站点取得网络信息时,是直接联系到目的站点服务器,然后由目的站点服务器把信息传送回来。代理服务器是介于客户端和Web服务器之间的另一台服务器,有了它之后,浏览器不是直接到Web服务器去取回网页而是向代理服务器发出请求,信号会先送到代理服务器,由代理服务器来取回浏览器所需要的信息并传送给你的浏览器。

比如你想访问的目的网站是A,由于某种原因你不能访问到网站A或者你不想直接访问网站A(这样通过代理服务器网站A,对网站A而已可以隐藏你自己的身份,也就是不知道是谁访问的网站,而认为是代理服务器访问的),此时你就可以使用代理服务器,在实际访问网站的时候,你在浏览器的地址栏内和你以前一样输入你要访问的网站,浏览器会自动先访问代理服务器,然后代理服务器会自动给你转接到你的目标网站。

代理服务器的作用

提高访问速度:通常代理服务器都设置一个较大的缓冲区,当有外界的信息通过时,同时也将其保存到缓冲区中,当其他用户再访问相同的信息时,则直接由缓冲区中取出信息,传给用户,以提高访问速度。

隐藏真实身份:上网者也可以通过代理服务器隐藏自己的真实地址信息,还可隐藏自己的IP,防止被黑客攻击。

突破限制:有时候网络供应商会对上网用户的端口,目的网站,协议,游戏,即时通讯软件等的限制,使用代理服务器都可以突破这些限制。

代理服务器主要类型

HTTP代理:最简单的一种代理形式,能够代理客户机的HTTP访问,上网浏览网页使用的都是HTTP协议,通常的HTTP代理端口为80、3128或8080端口。

SOCKS代理:SOCKS代理与HTTP等其他类型的代理不同,它只是简单地传递数据包,而并不关心是何种应用协议,既可以是HTTP协议,也可以是FTP协议,或者其他任何协议,所以SOCKS代理服务器比其他类型的代理服务器速度要快得多。SOCKS代理又分为SOCKS4和 SOCKS5,二者不同的是SOCKS4代理只支持TCP协议(即传输控制协议),而SOCKS5代理则既支持TCP协议又支持UDP协议(即用户数据包协议),还支持各种身份验证机制、服务器端远程域名解析(解决DNS污染就靠这个了)等。SOCK4能做到的SOCKS5都可得到,但SOCKS5能够做到的SOCKS则不一定能做到。目前SOCKS5是最常用的一种SOCKS代理。

如何使用HTTP代理服务器

HTTP代理服务器的设置方法,对于IE和FireFox设置略有不同。设置前需要先找一些可用的免费代理服务器地址

IE的设置是这样的,打开IE浏览器,选择菜单栏的“工具/Internet选项…”。

这时候分两种情况,对于ADSL拨号用户来说,选择一个网络连接后,点“设置”,如下图所示,选中代理服务器,填入地址和端口号。

clip_image001

对于局域网用户来说,需要点“局域网设置”,如下图所示,选中代理服务器,填入地址和端口号。

clip_image002

FireFox的设置和IE类似,打开FireFox浏览器,选择菜单栏的“工具/选项…”。

这时选择“高级/网络”,点设置,就出现下面的界面,就可以进行代理服务器的设置了,选中“手动配置代理”,然后填写代理服务器的地址和端口。

clip_image003

如何使用SOCKS代理服务器

这里就到重点内容了,SOCKS代理是目前功能最为全面,使用最为稳定的代理服务器,我目前上网就只用SSH搭建SOCKS代理服务器上网,访问网络没有任何限制。下面我就着重讲一下如何使用SOCKS代理服务器。

用SSH搭建SOCKS代理上网,建议使用Firefox浏览器,因为Firefox支持SOCKS代理远程域名解析,而IE只能通过类似SocksCap这样的第三方软件实现,不是很方便。

配置Firefox浏览器

在Firefox设置SOCKS远程域名解析,主要是为了防止DNS污染,具体设置方法是,在Firefox地址栏中,输入 about:config ,按确认,修改里面的一项数值,改成 network.proxy.socks_remote_dns=true 就可以了。

clip_image004

然后,打开FireFox浏览器,选择菜单栏的“工具/选项…”。选择“高级/网络”,点设置,就出现下面的界面,就可以进行代理服务器的设置了,选中“手动配置代理”,然后在SOCKS主机上,填写代理服务器的地址127.0.0.1,端口1080,SOCKS类型选择“SOCKS V5”,这时Firefox就配置结束。

clip_image005

设置SSH

配置好了Firefox,就该配置SSH了,安全外壳协议(Secure Shell Protocol / SSH)是一种在不安全网络上提供安全远程登录及其它安全网络服务的协议。常用的SSH工具有开源软件PuTTY,支持SSH远程登录的主机可以实现socks5代理服务器的功能,不过在PuTTY中没有配置文件,需要手动设置才能实现,且无法保存,而PuTTY完整版自带的pLink可以实现命令行方式调用PuTTY实现SSH的加密通道。

具体的方法是,去PuTTY官方网站下载pLink这个文件,pLink的调用参数是:plink -C -v -N -pw 密码 -D 本地端口 远程用户@IP或域名:远程希望打开的端口。

新建一个文件,写入以下内容,另存为pLink.bat批处理文件,并放在Putty的安装目录内。

plink -N Username@sshServer -pw Password -D 127.0.0.1:1080

请将Username sshServer Password三处改为用户自己登陆SSH服务器的用户名、服务器地址和密码。这个SSH帐号可以通过多种方法获得,例如用户购买了某些国外主机空间或VPS就会有SSH帐号,或者在淘宝网也有SSH帐号出售,我自用的SSH帐号是用每年100美元购买虚拟主机时赠送的,通常SSH帐号的价格大约是每年几十元人民币左右,也有少量国外网站提供免费的SSH帐号。

执行这个批处理文件,保持其窗口开启,一旦关闭窗口代理便失效。然后打开已经配置好127.0.0.1:1080的Socks5代理的Firefox浏览器,就可以使用SOCKS代理服务器上网了。

其他设置技巧

为了方便代理服务器的快速切换,我建议安装一个名为QuickProxyFireFox代理服务器扩展,可以实现一键切换代理功能,QuickProxy安装后在状态栏有一个按钮,点击后可以启用、关闭Firefox浏览器的默认代理设置,可以快速在代理和非代理之间切换,很方便。界面如下图所示。

clip_image006

设置完成了之后,你就可以自由自在地在开放的互联网上傲游了。根据我的使用经验,基于SSH的SOCKS代理稳定、快速、功能全面,是值得推荐的代理方法,使用过程中流量需要自己把控,我个人觉得其浏览体验要远远高于其他代理软件。

随着这次Google退出中国市场,本文可能会成为未来网民常用的上网技巧之一。

分类: 信息安全 标签: , ,

Google 你不能走!

2010年1月13日 hashei 2 条评论

昨天百度上了电视新闻,我权当看热闹,今天轮到了谷歌,这下我坐不住了。

一篇《A New Approach to China》掀起了今天的轩然大波,我订阅的RSS里,有关互联网的博客几乎都讲了这件事。

英文够好瞧这里 Google Just Says No to China

国内的文章我觉得这篇最详细,分析最透彻 宁为玉碎,不为瓦全

怎么说呢,如果google真退出中国,一并带走全部的产品,那我们IT行业就只剩下半条命了。遇到一般问题,开发人员还好,工作台上放几本工具书,有需要了就翻翻,但像我外勤的有时候记不起一个命令如何使用那只得靠google。

如果不是差个工具书就能解决的问题,而需要troubleshooting的话,那更得靠google。你琢磨破脑袋的问题,也许别人刚遇到过还写下来了,大家都琢磨不透的问题你一搜原来官方放出了补丁。google.cn搜不了了,那就换google.com,中文的有问没答那就换英文关键字。

没了google,你说用百度么?百度只适合娱乐、八卦和广告,有点深度的技术内容它是找不到的,找到的也是一篇篇白莲山的转载、垃圾网站的采集。

有人说这不过是google试探的手法,它也没正式宣布,只是在一个博客上放个风声,中国的市场它放弃不了的。我也希望如此,真怕它向我们展示一个有社会责任意识的公司会做的那样(今天google.cn的搜索结果就有些不老实了)。google真退出中国,对于90%的中国人应该是日子照过,但是对于我来说,那将是黑暗日子的开始。

分类: 生活感想 标签:

2010年的第一篇日志

2010年1月6日 hashei 1 条评论

居然两周没在这里更新,主要最近研究“三国杀”比较多,乱七八糟想的比较多。

新的一年要多读书,技术的和非技术的。过两天能拗到一本百来块的记事簿,就来写读书笔记好了。

交大的在职研究生应该没问题了,但是由于从事的工作不需要编程,要重新写起代码恐怕还需要努力一把。

一年年过的真是很快,真怕几年后看到自己还是原地踏步。在余晟的博客看到这么一段话,十分有感触。

每天花10分钟写日记,“想写什么就写什么,重要的是坚持,第一点要克服的障碍就是‘不想写’”。一年下来,记下了厚厚的一本:终于从信马由缰、恣意而为,到规律、精炼起来。更重要的是,通过持续的记述来感知和反思,加深对自己的认识;这有点像从各个不同的方向来照镜子,于是慢慢能认清自己的形象。

Mina Fighting!

分类: 生活感想 标签:

两个关于JAVA性能优化的PPT

2009年12月24日 hashei 2 条评论

Tools and Tips to Diagnose Performance Issues

分析性能问题的一些工具和建议

Use JMeter as a Performance Testing Tool

性能检测工具——Jmeter介绍

案例研究: 调优 WebSphere Application Server V7 性能

2009年12月23日 hashei 2 条评论

好东西,赶紧拉下来,介绍的太完整了,从内存调整到各种池大小优化。developerworks上都难得一见的完整调优案例。

原文链接:http://www.ibm.com/developerworks/cn/websphere/techjournal/0909_blythe/0909_blythe.html

IBM WebSphere Application Server 是一种可靠的企业级应用服务器,它提供了一组核心组件、资源和服务,供开发人员在应用程序中使用。每个应用程序都具备特有的需求,并且经常采用截然不同的方式使用应用服务器的资源。为了提供高度灵活性并支持这种广泛的应用程序,WebSphere Application Server 提供了一组全面的参数来帮助您增强对应用程序的调优。

应用服务器已经为最常用的调优参数设置了默认值,以确保能为最广泛的应用程序提供开箱即用的性能改善。但是,由于任意两个应用程序都不可能采用完全相同的方式来使用应用服务器,因此无法确保一组调优参数能适用于所有应用程序。这也突显了对应用程序执行有重点的性能测试和调优的重要性。

本文将讨论在 WebSphere Application Server V7.0(和之前发行版)中最常使用的一些参数,以及对它们进行调优的方法。与其他相关文章提供的调优建议不同,本文将使用 Apache DayTrader Performance Benchmark Sample 案例研究作为本文的上下文。借助 DayTrader 应用程序,您可以清楚地确定所使用的主要服务器组件,对这些区域进行重点调优,并观察各种调优更改所带来的收益。

在继续阅读之前,需要记住关于应用服务器性能调优的一些事项:

  • 提高性能经常会牺牲应用程序或应用服务器的一些特性或功能。在计算性能调优更改时应该仔细考虑性能和特性之间的权衡。
  • 应用服务器之外的一些因素有时会影响性能,包括硬件和操作系统配置、系统中运行的进程、后端数据库资源的性能、网络延迟等等。您在自己执行性能评估时,必须将这些因素考虑在内。
  • 此处讨论的性能改善仅针对 DayTrader 应用程序,并且特定于此处描述的工作负载组成及所支持的硬件和软件栈。您通过本文介绍的调优更改实现的应用程序性能提升肯定会有所不同,并且应该通过您自己的性能测试进行评估。

阅读全文…

IBM WebSphere最新技术支持信息

2009年12月20日 hashei 1 条评论

如果你想订阅这个邮件列表,发送邮件到wsehelp@us.ibm.com即可,邮件名称标注“subscribe WebSphere Application Server”

WebSphere Application Server Customer,
As a valued WebSphere Application Server customer who has contacted technical support, we are hoping you will find this information useful.
This note contains links to WebSphere Application Server technical support documents and information that can help you obtain value from your software. It is intended to help you to be proactive in your support and administration of WebSphere Application Server.

    • 1. Don’t be caught by surprise – try the IBM Support Portal today
      On January 6 the new IBM Support Portal, a unified, centralized view of all technical support tools and information for all IBM software, replaces the existing software product support pages. You can tailor the Support Portal to suit your needs, focusing on the software and hardware products you care about and organizing the pages to reflect the way you work. The portal makes it fast and easy to find the information or tools you need to prevent and resolve problems.We hope you can take a few minutes to fill out a short questionnaire that evaluates the IBM Support Portal in comparison to the existing IBM support website pages. We appreciate your feedback!
      2. IBM WebSphere Application Server Migration Toolkit
      The IBM WebSphere Application Server Migration Toolkit helps organizations migrate applications from other application servers to IBM WebSphere Application Server. WebSphere Application Server, a Java EE 5 certified, EJB 3.0 supported technology-based application platform, is a key part of the IBM Smart SOA Application Foundation that delivers the innovation and performance essential to cost-effectively build, deploy and manage robust SOA applications.
      http://www.ibm.com/developerworks/websphere/downloads/migration_toolkit.html
      3. developerWorks: WebSphere Application Server security
      This page of essential resources contains hints, tips, and valuable guidance to help you configure and use WebSphere Application Server security more effectively, and to design and develop your WebSphere Application Server solutions in ways that will make them more secure. Also included is information on the security environment in which WebSphere Application Server resides.
      http://www.ibm.com/developerworks/websphere/zones/was/security/
      4. Follow WebSphere Support on Twitter
      A list of available Twitter accounts for WebSphere Support.
      http://www.ibm.com/support/docview.wss?rs=180&uid=swg21410956
      5. WebSphere Application Server Feature Pack for XML
      The IBM WebSphere Application Server V7 Feature Pack for XML delivers updated XML programming model standards to help improve developer productivity and address new application development scenarios.
      http://www.ibm.com/software/webservers/appserv/was/featurepacks/xml/
      6. IBM Support Assistant – helping you simplify support
      If you haven’t tried the IBM Support Assistant yet, use the Quick Start Guide to find out what you’re missing! Save time with automated collectors and over 20 robust problem determination tools. IBM Support Assistant can be customized for over 350 IBM software products. The ISA Lite offering lets you quickly use the accurate, automated data collection capability. Download the workbench or ISA Lite to simplify support and save time. Not sure which one you need? Use the handy chart on the page to help you decide.
      7. The Support Authority: Know what your Web application is really doing
      The IBM Monitoring and Diagnostic Tools for Java – Health Center is a lightweight tool that monitors IBM virtual machines for Java with minimal performance overhead. It provides live information and recommendations about classes being loaded, the virtual machine environment, garbage collection, locking, and profiling. This article introduces you to the Health Center and shows an example of how it can be used to check the impact of a source code change in a Web application.
      http://www.ibm.com/developerworks/websphere/techjournal/0911_supauth/0911_supauth.html
      8. The Support Authority: Analyze memory management problems with the Memory Dump Diagnostic for Java (MDD4J)
      The Memory Dump Diagnostic for Java (MDD4J) tool helps you diagnose memory leaks and other excessive memory consumption problems in applications running in IBM Java Virtual Machines (JVMs). This article introduces you to MDD4J and shows you how to use its sophisticated analysis engine and user interface to peer into the Java heap so you can see which objects are consuming the most amount of memory.
      http://www.ibm.com/developerworks/websphere/techjournal/0909_supauth/0909_supauth.html
      9. One plug-in config to handle multiple Portal Applications in multiple Portal Clusters
      I have different Portal applications running in 2 different Portal Clusters. I want to use only 1 IBM HTTP Server Web server to route requests correctly for both applications in both clusters. How can I configure the Web server plug-in to accomplish this?
      http://www.ibm.com/support/docview.wss?rs=180&uid=swg21397408
      10. Web server plug-in routing to SAME application in DIFFERENT clusters
      If I install the same Web application into more than one WebSphere Application Server cluster, is it possible to configure the Web server plug-in to properly route requests to the application in both clusters?
      http://www.ibm.com/support/docview.wss?rs=180&uid=swg21331062
      11. IBM Service Integration Bus Destination Handler, Version 1.1
      A tool to view, move, copy, delete, save and restore messages in the default messaging provider for IBM WebSphere Application Server versions 7.0, 6.1, and 6.0.
      http://www.ibm.com/support/docview.wss?rs=180&uid=swg24021439
      12. Solution for installing 32-bit Java SDK fix packs on IBM HTTP Server V7.0 using Update Installer 7.0.0.5 and earlier
      For most operating systems and architectures, you should install the 32-bit Java SDK fix packs for IBM HTTP Server V7.0, even if that IBM HTTP Server was installed from the 64-bit Supplemental installation image. However, due to a defect in the process, Update Installer V7.0.0.5 and earlier will not allow you to install the 32-bit Java SDK fix pack, and will erroneously allow you to install the 64-bit Java SDK fix pack instead. This technote explains how to address this problem.
      http://www.ibm.com/support/docview.wss?rs=180&uid=swg21395882

      1. WebSphere Application Server Administration Using Jython
      Utilizing Jython scripting, you can dramatically reduce the effort, resources, and expense associated with managing WebSphere Application Server. WebSphere Application Server Administration Using Jython will show you how. The first start-to-finish guide to Jython scripting for WebSphere administration, this book’s practical techniques and downloadable scripts can help you improve efficiency, repeatability, and automation in any WebSphere environment.
      *Using coupon code IBM9527 provides you a 35% discount AND Free Shipping!
      http://www.ibmpressbooks.com/bookstore/product.asp?isbn=0137009526
      2. Join us for these Electronic Support webcasts
      During the month of January, the Global WebSphere Community will offer a series of four electronic support webcasts. Check the web site for details on joining the webcasts:
      January 7 webcast – “It’s official – the IBM Support Portal is here!”
      January 14 webcast – “Quick guide to electronic support and a close look at the Service Request tool”
      January 21 webcast – “Discover IBM Support Assistant – ready to help when you need it”
      January 28 webcast – “IBM portfolio of troubleshooting tools: helping you solve problems faster”
      3. IBM WebSphere Application Server V7.0 Web Services Guide
      This IBM Redbooks publication describes how to implement Web services in IBM WebSphere Application Server V7. It starts by describing the concepts of the major building blocks on which Web services rely and leading practices for Web services applications.
      http://www.redbooks.ibm.com/abstracts/SG247758.html
      4. Technical Exchange Webcasts
      Take full advantage of your product. Join us as technical experts share their knowledge and then answer your questions. Visit this site often to see upcoming topics.
      http://www.ibm.com/software/websphere/support/supp_tech.html
      5. Self-Assist Resources and Tools
      Find out how online software support tools and resources can save you time, keep you informed, provide training, and help streamline your support experience!
      http://www.ibm.com/software/websphere/support/d2w.html
      6. developerWorks WebSphere Application Server zone
      Access the developerWorks page for downloads, learning resources and more.
      http://www.ibm.com/developerworks/websphere/zones/was/
  • In the spotlightPlan

    Education

Kind regards,
The WebSphere Application Server team.