快讯资讯
手机优化
系统数码
网络通信人工智能
网站游戏
测评专题

  Nginx反向代理Google       systemd详解    

Nginx反向代理Google

时间:2026-09-10 00:12 来源:未知 人气:

最近google被墙,工作效率严重下降,baidu不出来东东,刚刚看到CentOS.bz的《Nginx反向代理谷歌》于是自己也搭建了一个,速度杠杠的。有国外vps的朋友可以试试,声明:有风险,IP或者域名有被墙的可能。

基于《lnmp一键安装包》,将 --with-http_sub_module、ngx_cache_purge-2.1编译到nginx中,如下:

cd ~/lnmp/src wget http://labs.frickle.com/files/ngx_cache_purge-2.1.tar.gz tar xzf ngx_cache_purge-2.1.tar.gz cd nginx-1.6.1 make clean ./configure --prefix=/usr/local/nginx --user=www --group=www --add-module=../ngx_cache_purge-2.1 \ --with-http_sub_module --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module \ --with-http_gzip_static_module --with-ld-opt=-ljemalloc make mv /usr/local/nginx/sbin/nginx{,$(date +%m%d)} cp objs/nginx /usr/local/nginx/sbin service nginx restart mkdir -p /var/nginx/cache/one chown -R www.www /var/nginx

自己签发免费ssl证书,为nginx生成自签名ssl证书(访问时需添加信任。也可以使用第三方签名后的证书,如免费的startssl)

cd /usr/local/nginx/conf openssl genrsa -out server.key 1024 openssl req -new -key server.key -out server.csr openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

nginx.conf 配置文件如下(注意: 74.xx.xx.xx替换成域名或者IP):

proxy_cache_path /var/nginx/cache/one  levels=1:2   keys_zone=one:10m max_size=10g; proxy_cache_key "$host$request_uri"; upstream google {         server 74.125.239.112:80 max_fails=3;         server 74.125.239.113:80 max_fails=3;         server 74.125.239.114:80 max_fails=3;         server 74.125.239.115:80 max_fails=3;         server 74.125.239.116:80 max_fails=3; } server {         listen 80;         server_name 74.xx.xx.xx;         rewrite ^(.*) https://74.xx.xx.xx$1 permanent; } server { listen 443; server_name 74.xx.xx.xx ssl on; ssl_certificate /usr/local/nginx/conf/server.crt; ssl_certificate_key /usr/local/nginx/conf/server.key; location / {         proxy_cache one;         proxy_cache_valid  200 302 1h;         proxy_cache_valid  404 1m;         proxy_redirect https://www.google.com/ /;         proxy_cookie_domain google.com 74.xx.xx.xx;         proxy_pass http://google;         proxy_set_header Host "www.google.com";         proxy_set_header Accept-Encoding "";         proxy_set_header User-Agent $http_user_agent;         proxy_set_header Accept-Language "zh-CN";         proxy_set_header Cookie "PREF=ID=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2w1IQ-Maw";         sub_filter www.google.com 74.xx.xx.xx ;         sub_filter_once off;         } }

注解:

1、监听了80和443端口,可以在Linux自己生成证书。

本文标签:

更多文章

相关文章

网站导航 | 快讯 | 资讯 | 手机 | 优化

  • 数码 | 网络通信 | 人工智能 | 网站 | 游戏

    合作伙伴:

  • 友情链接(欢迎业界知名网站交换链接)申请友情

    

    声明:本站资源皆来自网络,如有侵权问题,请联系管理员处理!

    Copyright ©2020-2028快知站 版权所有 All rights reserved.

    闽ICP备20010713号-1 闽公网安备 35020602001684号