<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>深度VPS &#187; 反向代理</title>
	<atom:link href="http://www.deepvps.com/tag/%E5%8F%8D%E5%90%91%E4%BB%A3%E7%90%86/feed" rel="self" type="application/rss+xml" />
	<link>http://www.deepvps.com</link>
	<description>专注VPS技术，关注前端技术</description>
	<lastBuildDate>Sat, 04 Feb 2023 14:00:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CentOS 安装配置Squid反向代理服务器详细教程</title>
		<link>http://www.deepvps.com/install-squid.html</link>
		<comments>http://www.deepvps.com/install-squid.html#comments</comments>
		<pubDate>Sun, 26 May 2013 13:38:36 +0000</pubDate>
		<dc:creator>deepvps</dc:creator>
				<category><![CDATA[网络杂谈]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[反向代理]]></category>

		<guid isPermaLink="false">http://www.deepvps.com/?p=1350</guid>
		<description><![CDATA[squid是一个缓存服务，它还是一个反向代理服务，还能用于负载均衡与前端处理。squid的配置文件灵活，功能强大。它的原理是接受用户的http请求，然后根据配置文件，从源服务器得到这个请求的文件，然后返回给用户，与此同时，它将根据情况保留（缓存）一份这个文件，下次再有用户需要请求这个文件，将可以直接快速的返回给用户。
squid并没有复杂的安装配置过程，在了解原理之后其实非常简单。这里给出一个简单的squid安装与配置例子。
安装squid
对于CentOS系统，安装squid采用如下命令：
yum install squid
配置Apache
首先确保Apache正常安装，默认情况下Apache的监听端口是80端口，现在将其修改为81端口：
[root@www ~]# vi /etc/httpd/conf/httpd.conf
找到Listen 80，将其修改为
Listen 81
配置squid
squid的配置文件位于： /etc/squid/squid.conf
/etc/squid/目录下还有一个名为squid.conf.default的文件，是默认的配置。仅在squid.conf修改乱了之后用于还原配置。squid的配置文件还是比较松散的，顺序基本上没什么要求，也没有太多的层次。每行语句都比较独立。
原配置文件有几千行，绝大多数是注释，干脆手动将其删除，然后重新输入。
[root@www ~]# rm /etc/squid/squid.conf -f &#38;&#38; vi /etc/squid/squid.conf
visible_hostname www.abc.com
http_port 80 vhost
cache_mem 256 MB
maximum_object_size_in_memory 2048 KB
cache_dir ufs /tmp 512 16 256
minimum_object_size 0 KB
maximum_object_size 32768 KB
acl all src 0.0.0.0/0.0.0.0
http_access allow all
cache_peer www.abc.com parent 81 0 no-query originserver weight=1 name=www
cache_peer_domain www www.abc.com
上面的www.abc.com只是举例子，需根据情况进行修改。上述例子是squid与Apache在同一台服务器的情况。
测试squid性能
如下命令用于显示squid使用情况：
[root@www ~]# squidclient -p 80 -h localhost mgr:info
HTTP/1.0 200 [...]]]></description>
			<content:encoded><![CDATA[<p>squid是一个缓存服务，它还是一个反向代理服务，还能用于负载均衡与前端处理。squid的配置文件灵活，功能强大。它的原理是接受用户的http请求，然后根据配置文件，从源服务器得到这个请求的文件，然后返回给用户，与此同时，它将根据情况保留（缓存）一份这个文件，下次再有用户需要请求这个文件，将可以直接快速的返回给用户。</p>
<p>squid并没有复杂的安装配置过程，在了解原理之后其实非常简单。这里给出一个简单的squid安装与配置例子。<span id="more-1350"></span></p>
<h3>安装squid</h3>
<p>对于CentOS系统，安装squid采用如下命令：</p>
<blockquote><p>yum install squid</p></blockquote>
<h3>配置Apache</h3>
<p>首先确保Apache正常安装，默认情况下Apache的监听端口是80端口，现在将其修改为81端口：</p>
<blockquote><p>[root@www ~]# vi /etc/httpd/conf/httpd.conf</p></blockquote>
<p>找到Listen 80，将其修改为</p>
<blockquote><p>Listen 81</p></blockquote>
<h3>配置squid</h3>
<p>squid的配置文件位于： /etc/squid/squid.conf<br />
/etc/squid/目录下还有一个名为squid.conf.default的文件，是默认的配置。仅在squid.conf修改乱了之后用于还原配置。squid的配置文件还是比较松散的，顺序基本上没什么要求，也没有太多的层次。每行语句都比较独立。</p>
<p>原配置文件有几千行，绝大多数是注释，干脆手动将其删除，然后重新输入。</p>
<blockquote><p>[root@www ~]# rm /etc/squid/squid.conf -f &amp;&amp; vi /etc/squid/squid.conf</p>
<p>visible_hostname www.abc.com<br />
http_port 80 vhost<br />
cache_mem 256 MB<br />
maximum_object_size_in_memory 2048 KB<br />
cache_dir ufs /tmp 512 16 256<br />
minimum_object_size 0 KB<br />
maximum_object_size 32768 KB<br />
acl all src 0.0.0.0/0.0.0.0<br />
http_access allow all<br />
cache_peer www.abc.com parent 81 0 no-query originserver weight=1 name=www<br />
cache_peer_domain www www.abc.com</p></blockquote>
<p>上面的www.abc.com只是举例子，需根据情况进行修改。上述例子是squid与Apache在同一台服务器的情况。</p>
<h3>测试squid性能</h3>
<p>如下命令用于显示squid使用情况：</p>
<blockquote><p>[root@www ~]# squidclient -p 80 -h localhost mgr:info<br />
HTTP/1.0 200 OK<br />
Server: squid/2.6.STABLE21<br />
Date: Fri, 13 Jan 2012 13:52:06 GMT<br />
Content-Type: text/plain<br />
Expires: Fri, 13 Jan 2012 13:52:06 GMT<br />
Last-Modified: Fri, 13 Jan 2012 13:52:06 GMT<br />
X-Cache: MISS from www.abc.com<br />
X-Cache-Lookup: MISS from www.abc.com:80<br />
Via: 1.0 www.abc.com:80 (squid/2.6.STABLE21)<br />
Connection: close<br />
Squid Object Cache: Version 2.6.STABLE21<br />
Start Time: Fri, 13 Jan 2012 13:45:03 GMT<br />
Current Time: Fri, 13 Jan 2012 13:52:06 GMT</p>
<p>Connection information for squid:<br />
Number of clients accessing cache: 2<br />
Number of HTTP requests received: 20010<br />
Number of ICP messages received: 0<br />
Number of ICP messages sent: 0<br />
Number of queued ICP replies: 0<br />
Request failure ratio: 0.00<br />
Average HTTP requests per minute since start: 2839.7<br />
Average ICP messages per minute since start: 0.0<br />
Select loop called: 2681 times, 157.699 ms avg</p>
<p>Cache information for squid:<br />
Request Hit Ratios: 5min: 99.4%, 60min: 99.4%  #这个命中率已经暴殄天物了（当然，只是用ab进行了测试）<br />
Byte Hit Ratios: 5min: 99.4%, 60min: 99.4%<br />
Request Memory Hit Ratios: 5min: 0.0%, 60min: 0.0%<br />
Request Disk Hit Ratios: 5min: 0.0%, 60min: 0.0%<br />
Storage Swap size: 8 KB<br />
Storage Mem size: 124 KB<br />
Mean Object Size: 4.00 KB<br />
&#8230;</p></blockquote>
<p>我用ab命令对80 squid端口与81 apache端口同时进行了多次测试：</p>
<blockquote><p>[root@www ~]# ab -n 10000 -c 100 http://www.abc.com:81/</p>
<p>与</p>
<p>[root@www ~]# ab -n 10000 -c 100 http://www.abc.com/</p></blockquote>
<p>其中采用squid后 Requests per second: 7786.69 [#/sec] (mean)<br />
不采用squid 时 Requests per second: 4766.30 [#/sec] (mean)</p>
<p>看来squid的性能的确优异。Squid还支持多台后端服务器进行负载均衡与自动宕机切换，这篇文章仅仅是抛砖引玉，具体方法等有空了以后介绍。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepvps.com/install-squid.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CentOS 安装配置squid反向代理服务器教程</title>
		<link>http://www.deepvps.com/install-squid-on-centos.html</link>
		<comments>http://www.deepvps.com/install-squid-on-centos.html#comments</comments>
		<pubDate>Mon, 10 Sep 2012 15:04:55 +0000</pubDate>
		<dc:creator>deepvps</dc:creator>
				<category><![CDATA[VPS管理维护]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[反向代理]]></category>

		<guid isPermaLink="false">http://www.deepvps.com/?p=1191</guid>
		<description><![CDATA[squid是一个缓存服务，它还是一个反向代理服务，还能用于负载均衡与前端处理。squid的配置文件灵活，功能强大。它的原理是接受用户的http请求，然后根据配置文件，从源服务器得到这个请求的文件，然后返回给用户，与此同时，它将根据情况保留（缓存）一份这个文件，下次再有用户需要请求这个文件，将可以直接快速的返回给用户。
squid并没有复杂的安装配置过程，在了解原理之后其实非常简单。deepvps给出一个简单的squid安装与配置例子。
安装squid
对于CentOS系统，安装squid采用如下命令：
yum install squid
配置Apache
首先确保Apache正常安装，默认情况下Apache的监听端口是80端口，现在将其修改为81端口：
[root@www ~]# vi /etc/httpd/conf/httpd.conf
找到Listen 80，将其修改为
Listen 81
配置squid
squid的配置文件位于： /etc/squid/squid.conf
/etc/squid/目录下还有一个名为squid.conf.default的文件，是默认的配置。仅在squid.conf修改乱了之后用于还原配置。squid的配置文件还是比较松散的，顺序基本上没什么要求，也没有太多的层次。每行语句都比较独立。
原配置文件有几千行，绝大多数是注释，干脆手动将其删除，然后重新输入。
[root@www ~]# rm /etc/squid/squid.conf -f &#38;&#38; vi /etc/squid/squid.conf
visible_hostname www.abc.com
http_port 80 vhost
cache_mem 256 MB
maximum_object_size_in_memory 2048 KB
cache_dir ufs /tmp 512 16 256
minimum_object_size 0 KB
maximum_object_size 32768 KB
acl all src 0.0.0.0/0.0.0.0
http_access allow all
cache_peer www.bootf.com parent 81 0 no-query originserver weight=1 name=www
cache_peer_domain www www.abc.com
上面的www.abc.com只是举例子，需根据情况进行修改。上述例子是squid与Apache在同一台服务器的情况。
测试squid性能
如下命令用于显示squid使用情况：
[root@www ~]# squidclient -p 80 -h localhost mgr:info
HTTP/1.0 200 [...]]]></description>
			<content:encoded><![CDATA[<p>squid是一个缓存服务，它还是一个反向代理服务，还能用于负载均衡与前端处理。squid的配置文件灵活，功能强大。它的原理是接受用户的http请求，然后根据配置文件，从源服务器得到这个请求的文件，然后返回给用户，与此同时，它将根据情况保留（缓存）一份这个文件，下次再有用户需要请求这个文件，将可以直接快速的返回给用户。</p>
<p>squid并没有复杂的安装配置过程，在了解原理之后其实非常简单。deepvps给出一个简单的squid安装与配置例子。<span id="more-1191"></span></p>
<h3>安装squid</h3>
<p>对于CentOS系统，安装squid采用如下命令：</p>
<blockquote><p>yum install squid</p></blockquote>
<h3>配置Apache</h3>
<p>首先确保Apache正常安装，默认情况下Apache的监听端口是80端口，现在将其修改为81端口：</p>
<blockquote><p>[root@www ~]# vi /etc/httpd/conf/httpd.conf</p></blockquote>
<p>找到Listen 80，将其修改为</p>
<blockquote><p>Listen 81</p></blockquote>
<h3>配置squid</h3>
<p>squid的配置文件位于： /etc/squid/squid.conf</p>
<p>/etc/squid/目录下还有一个名为squid.conf.default的文件，是默认的配置。仅在squid.conf修改乱了之后用于还原配置。squid的配置文件还是比较松散的，顺序基本上没什么要求，也没有太多的层次。每行语句都比较独立。</p>
<p>原配置文件有几千行，绝大多数是注释，干脆手动将其删除，然后重新输入。</p>
<blockquote><p>[root@www ~]<span style="color: #008000;"># rm /etc/squid/squid.conf -f &amp;&amp; vi /etc/squid/squid.conf</span></p>
<p>visible_hostname www.abc.com<br />
http_port 80 vhost<br />
cache_mem 256 MB<br />
maximum_object_size_in_memory 2048 KB<br />
cache_dir ufs /tmp 512 16 256<br />
minimum_object_size 0 KB<br />
maximum_object_size 32768 KB<br />
acl all src 0.0.0.0/0.0.0.0<br />
http_access allow all<br />
cache_peer www.bootf.com parent 81 0 no-query originserver weight=1 name=www<br />
cache_peer_domain www www.abc.com</p></blockquote>
<p>上面的www.abc.com只是举例子，需根据情况进行修改。上述例子是squid与Apache在同一台服务器的情况。</p>
<h3>测试squid性能</h3>
<p>如下命令用于显示squid使用情况：</p>
<blockquote><p>[root@www ~]# squidclient -p 80 -h localhost mgr:info<br />
HTTP/1.0 200 OK<br />
Server: squid/2.6.STABLE21<br />
Date: Fri, 13 Jan 2012 13:52:06 GMT<br />
Content-Type: text/plain<br />
Expires: Fri, 13 Jan 2012 13:52:06 GMT<br />
Last-Modified: Fri, 13 Jan 2012 13:52:06 GMT<br />
X-Cache: MISS from www.abc.com<br />
X-Cache-Lookup: MISS from www.abc.com:80<br />
Via: 1.0 www.abc.com:80 (squid/2.6.STABLE21)<br />
Connection: close<br />
Squid Object Cache: Version 2.6.STABLE21<br />
Start Time: Fri, 13 Jan 2012 13:45:03 GMT<br />
Current Time: Fri, 13 Jan 2012 13:52:06 GMT</p>
<p>Connection information for squid:<br />
Number of clients accessing cache: 2<br />
Number of HTTP requests received: 20010<br />
Number of ICP messages received: 0<br />
Number of ICP messages sent: 0<br />
Number of queued ICP replies: 0<br />
Request failure ratio: 0.00<br />
Average HTTP requests per minute since start: 2839.7<br />
Average ICP messages per minute since start: 0.0<br />
Select loop called: 2681 times, 157.699 ms avg</p>
<p>Cache information for squid:<br />
Request Hit Ratios: 5min: 99.4%, 60min: 99.4%  #这个命中率已经暴殄天物了<br />
Byte Hit Ratios: 5min: 99.4%, 60min: 99.4%<br />
Request Memory Hit Ratios: 5min: 0.0%, 60min: 0.0%<br />
Request Disk Hit Ratios: 5min: 0.0%, 60min: 0.0%<br />
Storage Swap size: 8 KB<br />
Storage Mem size: 124 KB<br />
Mean Object Size: 4.00 KB<br />
&#8230;</p></blockquote>
<p>用ab命令对80 squid端口与81 apache端口同时进行了多次测试：</p>
<p>[root@www ~]# ab -n 10000 -c 100 http://www.abc.com:81/</p>
<p>与</p>
<p>[root@www ~]# ab -n 10000 -c 100 http://www.abc.com</p>
<p>其中采用squid后 Requests per second: 7786.69 [#/sec] (mean)<br />
不采用squid 时 Requests per second: 4766.30 [#/sec] (mean)</p>
<p>看来squid的性能的确优异。Squid还支持多台后端服务器进行负载均衡与自动宕机切换，这篇文章仅仅是抛砖引玉，具体方法等有空了以后介绍。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepvps.com/install-squid-on-centos.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Linux VPS上配置Nginx反向代理</title>
		<link>http://www.deepvps.com/linux-vps-nginx-reverse-proxy.html</link>
		<comments>http://www.deepvps.com/linux-vps-nginx-reverse-proxy.html#comments</comments>
		<pubDate>Mon, 12 Apr 2010 09:34:37 +0000</pubDate>
		<dc:creator>deepvps</dc:creator>
				<category><![CDATA[VPS管理维护]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[反向代理]]></category>

		<guid isPermaLink="false">http://www.deepvps.com/?p=373</guid>
		<description><![CDATA[Nginx是一款高性能的HTTP和反向代理服务器。deepvps以前已经多次介绍过Nginx的HTTP应用，比如lnmp一键安装包。下面要说的是Nginx的反向代理功能。
反向代理是什么？
反向代理指以代理服务器来接受Internet上的连接请求，然后将请求转发给内部(或其他)网络上的服务器，并将从服务器上得到的结果返回给Internet上请求连接的客户端。
实现方法：
比如我想在VPS上建一个t.deepvps.com的域名用来反向代理访问twitter，首先在域名注册商那里的域名管理上为域名t.vpser.net添加A记录到VPS的IP上，再在VPS上修改Nginx的配置文件，添加如下：
server
	{
    	listen          80;
    	server_name     t.deepvps.com;

    	location / {
        	proxy_pass              http://twitter.com/;
    [...]]]></description>
			<content:encoded><![CDATA[<p>Nginx是一款高性能的HTTP和反向代理服务器。<a href="http://www.deepvps.com/" target="_blank">deepvps</a>以前已经多次介绍过Nginx的HTTP应用，比如<a href="http://www.deepvps.com/lnmp-3-17.html" target="_blank">lnmp一键安装包</a>。下面要说的是<a href="http://www.deepvps.com/linux-vps-nginx-reverse-proxy.html" target="_blank">Nginx的反向代理功能</a>。<span id="more-373"></span></p>
<p><strong>反向代理是什么？</strong></p>
<p>反向代理指以代理服务器来接受Internet上的连接请求，然后将请求转发给内部(或其他)网络上的服务器，并将从服务器上得到的结果返回给Internet上请求连接的客户端。</p>
<p><strong>实现方法：</strong></p>
<p>比如我想在VPS上建一个t.deepvps.com的域名用来反向代理访问twitter，首先在域名注册商那里的域名管理上为域名t.vpser.net添加A记录到VPS的IP上，再在VPS上修改Nginx的配置文件，添加如下：</p>
<pre>server
	{
    	listen          80;
    	server_name     <a href="http://www.vpser.net;/">t.deepvps.com;
</a>
    	location / {
        	proxy_pass              http://twitter.com/;
        	proxy_redirect          off;
        	proxy_set_header        X-Real-IP       $remote_addr;
        	proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        	}
	}</pre>
<p>添加好后，先执行：/usr/local/nginx/sbin/nginx -t 检查配置是否正常，如果显示：the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok      configuration file /usr/local/nginx/conf/nginx.conf test is successful 则正常，否则按错误提示修改配置。</p>
<p>再执行 kill -HUP `cat /usr/local/nginx/logs/nginx.pid` 使配置生效，域名解析生效后就可以通过t.vpser.net 访问twitter了。</p>
<p>转载自：VPS侦探 <a href="http://www.vpser.net/">http://www.VPSer.Net</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.deepvps.com/linux-vps-nginx-reverse-proxy.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
