<?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>服务器安全维护工作室 &#187; squid</title>
	<atom:link href="https://www.fuwuqiok.com/tag/squid/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fuwuqiok.com</link>
	<description></description>
	<lastBuildDate>Sun, 01 Mar 2020 07:28:40 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.26</generator>
	<item>
		<title>通过vpn搭建squid stunnel 代理服务器成功访问google</title>
		<link>https://www.fuwuqiok.com/%e9%80%9a%e8%bf%87vpn%e6%90%ad%e5%bb%basquid-stunnel-%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%88%90%e5%8a%9f%e8%ae%bf%e9%97%aegoogle/</link>
		<comments>https://www.fuwuqiok.com/%e9%80%9a%e8%bf%87vpn%e6%90%ad%e5%bb%basquid-stunnel-%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%88%90%e5%8a%9f%e8%ae%bf%e9%97%aegoogle/#comments</comments>
		<pubDate>Fri, 06 Nov 2015 07:34:05 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[系统安全代维]]></category>
		<category><![CDATA[网站代维]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[stunnel]]></category>
		<category><![CDATA[代理服务器]]></category>
		<category><![CDATA[安装]]></category>
		<category><![CDATA[配置]]></category>

		<guid isPermaLink="false">https://www.fuwuqiok.com/?p=2756</guid>
		<description><![CDATA[<p>最近公司有一需求 通过国内服务器要访问国外的google推送服务器https://android.google [&#8230;]</p>
<p><a rel="nofollow" href="https://www.fuwuqiok.com/%e9%80%9a%e8%bf%87vpn%e6%90%ad%e5%bb%basquid-stunnel-%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%88%90%e5%8a%9f%e8%ae%bf%e9%97%aegoogle/">通过vpn搭建squid stunnel 代理服务器成功访问google</a>，首发于<a rel="nofollow" href="https://www.fuwuqiok.com">服务器安全维护工作室</a>。</p>
]]></description>
				<content:encoded><![CDATA[<p>最近公司有一需求</p>
<p>通过国内服务器要访问国外的google推送服务器https://android.googleapis.com/gcm/send</p>
<p>刚开始想过通过搭建vpn来实现，但由于公司两边都是使用linux服务器，考虑到风险，暂时没有使用这种方法</p>
<p>后来通过各种方法的测试，最后总结出一套好的办法来实现</p>
<p>方案squid认证代理+stunnel</p>
<p>此种方法前提条件是有一台自己的vps机器</p>
<p>配置步骤如下：</p>
<p>二，服务端安装squid</p>
<p>1，安装squid</p>
<p># yum install squid openssl openssl-devel</p>
<p>2，生成加密代理证书</p>
<p># cd /etc/squid<br />
# openssl req -new &gt; example.csr    //要求输入密码和确认密码<br />
# openssl rsa -in privkey.pem -out example.key  //输入上面输入的密码<br />
# openssl x509 -in example.csr -out example.crt -req -signkey example.key -days 3650</p>
<p>生成认证用户</p>
<p># touch /etc/squid/passwd<br />
# chown root.squid /etc/squid/passwd<br />
# chmod 640 /etc/squid/passwd</p>
<p># /usr/local/apache/bin/htpasswd /etc/squid/passwd 360push</p>
<p>3，配置squid</p>
<p># vim /etc/squid/squid.conf</p>
<p>visible_hostname push.360push.com</p>
<p>acl localnet src 172.16.0.0/12  # RFC1918 possible internal network<br />
acl localnet src 182.150.2.130/32  //push client</p>
<p>acl SSL_ports port 443<br />
acl Safe_ports port 443         # https<br />
acl Safe_ports port 1025-65535  # unregistered ports<br />
acl CONNECT method CONNECT</p>
<p>https_port 443 cert=/etc/squid/example.crt key=/etc/squid/example.key</p>
<p>http_access deny !Safe_ports<br />
http_access deny CONNECT !SSL_ports</p>
<p>http_access allow localhost manager<br />
http_access deny manager<br />
http_access allow localnet<br />
http_access allow localhost<br />
http_access deny all</p>
<p>cache_dir ufs /var/spool/squid 2048 16 256<br />
coredump_dir /var/spool/squid</p>
<p>acl OverConnLimit maxconn 100   //限制每个IP最大允许10个连接，防止攻击<br />
minimum_object_size 1 KB      //允午最小文件请求体大小<br />
maximum_object_size 1 MB      //允午最大文件请求体大小<br />
cache_swap_low 10             //最小允许使用swap 10%<br />
cache_swap_high 25            //最大允许使用swap 25%<br />
cache_mem 300 MB              //可使用内存</p>
<p>##Add auth##<br />
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd<br />
auth_param basic children 5<br />
auth_param basic credentialsttl 12 hours<br />
auth_param basic realm Push Server<br />
acl 360push proxy_auth REQUIRED</p>
<p>vps硬盘，内存都不富裕，所以对squid所占用的内存和硬盘等要加以控制。</p>
<p>4，启动squid，并查看</p>
<p># squid -z   生成交换文件</p>
<p># squid -k parse  检查配置文件正确性</p>
<p># /etc/init.d/squid start</p>
<p>VPS很少有，自启动开启防火墙的，如果有先关掉，等都配置好了，在开放端口。</p>
<p>三，客户端安装配置stunnel</p>
<p>1，安装</p>
<p># yum install stunnel</p>
<p>2，新增配置/etc/stunnel/stunnel.conf，添加以下内空</p>
<p>client = yes<br />
fips = no<br />
[https]
accept = 8888<br />
connect = VPS的IP:443</p>
<p>如果报，FIPS_mode_set: 2D06C06E: error:2D06C06E:FIPS routines:FIPS_module_mode_set:fingerprint does not match，stunnel.conf配置文件中加上，fips = no</p>
<p>3，启动stunnel并查看</p>
<p># stunnel            //启动，默认配置文件路径 /etc/stunnel/stunnel.conf</p>
<p>curl本机测试</p>
<p>curl -v -x 127.0.0.1:8888 -U 360push:360push https://android.googleapis.com/gcm/send</p>
<p>php也可以利用代理服务器</p>
<p>function testCurl($url){<br />
$ch = curl_init();<br />
curl_setopt($ch, CURLOPT_URL, $gurl);<br />
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br />
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);<br />
curl_setopt($ch, CURLOPT_PROXY, &#8220;127.0.0.1:8888&#8243;);    //ip/端口<br />
curl_setopt($ch, CURLOPT_PROXYUSERPWD, &#8216;360push:360push&#8217;);  //认证用户和密码<br />
$result=curl_exec($ch);<br />
curl_close($ch);<br />
return $result;<br />
}</p>
<p>echo testCurl(&#8220;google.com&#8221;);</p>
<p>google提示错误，如下</p>
<p>We&#8217;re sorry&#8230; but your computer or network may be sending automated queries. To protect our users, we can&#8217;t process your request right now</p>
<p>解决办法。</p>
<p>方法一：编辑 /etc/sysctl.conf,添加如下内容</p>
<p>net.ipv6.conf.all.disable_ipv6=1<br />
net.ipv6.conf.default.disable_ipv6=1<br />
net.ipv6.conf.lo.disable_ipv6=1</p>
<p>重启网卡</p>
<p># /etc/init.d/networking restart</p>
<p>方法二，实时生效</p>
<p>echo &#8216;1&#8217; &gt; /proc/sys/net/ipv6/conf/lo/disable_ipv6<br />
echo &#8216;1&#8217; &gt; /proc/sys/net/ipv6/conf/lo/disable_ipv6<br />
echo &#8216;1&#8217; &gt; /proc/sys/net/ipv6/conf/all/disable_ipv6<br />
echo &#8216;1&#8217; &gt; /proc/sys/net/ipv6/conf/default/disable_ipv6</p>
<p><a rel="nofollow" href="https://www.fuwuqiok.com/%e9%80%9a%e8%bf%87vpn%e6%90%ad%e5%bb%basquid-stunnel-%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%88%90%e5%8a%9f%e8%ae%bf%e9%97%aegoogle/">通过vpn搭建squid stunnel 代理服务器成功访问google</a>，首发于<a rel="nofollow" href="https://www.fuwuqiok.com">服务器安全维护工作室</a>。</p>
]]></content:encoded>
			<wfw:commentRss>https://www.fuwuqiok.com/%e9%80%9a%e8%bf%87vpn%e6%90%ad%e5%bb%basquid-stunnel-%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%88%90%e5%8a%9f%e8%ae%bf%e9%97%aegoogle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
