ghs.google.com域名反向代理

作者: mikj 分类: google, ipv6, linux, vps, 建站学习, 资源分享 发布时间: 2010-05-04 09:56 ė 6没有评论

Google的App服务可以用自定义地址来访问,只需要在Google App设置里设置为自定义的域名,然后设置域名的CNAME到ghs.google.com。但这个ghs.google.com在国内被屏蔽了,直接按google默认要求的做是无法使用自定义域名访问App服务的,解决的方法是nginx的反向代理服务。前提是已经安装好nginx,在/user/local/nginx/conf/nginx.conf中,添加一段类似server{…}的代码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
upstream ghs {
   ip_hash;
   server ghs.google.com;
   server 72.14.203.121;
   server 72.14.207.121;
   server 74.125.43.121;
   server 74.125.47.121;
   server 74.125.53.121;
   server 74.125.77.121;
   server 74.125.93.121;
   server 74.125.95.121;
   server 74.125.113.121;
   server 216.239.32.21;
   server 216.239.34.21;
   server 216.239.36.21;
   server 216.239.38.21;
 }

server {
listen 80;
server_name  ghs.domain.com;
location /  {
     proxy_set_header Host $host;
     proxy_pass http://ghs;
     proxy_set_header  X-Real-IP  $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

然后重启:

1
2
3
killall nginx

/usr/local/nginx/sbin/nginx
第2个方案:
upstream ghs {
   ip_hash;
   server ghs.google.com;
   server 72.14.203.121;
   server 72.14.207.121;
   server 74.125.43.121;
   server 74.125.47.121;
   server 74.125.53.121;
   server 74.125.77.121;
   server 74.125.93.121;
   server 74.125.95.121;
   server 74.125.113.121;
   server 216.239.32.21;
   server 216.239.34.21;
   server 216.239.36.21;
   server 216.239.38.21;
}

server {
   listen       你vpsIP:80;
   server_name  ghs.dmain.com;
#下行中的ghs换成自己定义的名称。
    log_format  ghs  '$remote_addr - $remote_user [$time_local] "$request" '
               '$status $body_bytes_sent "$http_referer" '
               '"$http_user_agent" $http_x_forwarded_for';
#下行中两处ghs换成自己定义的名称。
   access_log  /home/log/ghs.log ghs;

   location / {
     proxy_redirect off;
     proxy_set_header Host $host;
     proxy_pass http://ghs;
     proxy_set_header  X-Real-IP  $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_redirect false;
   }

}

server {
   listen       你vpsIP:443;
   server_name  ghs.dmain.com;
   log_format  mail  '$remote_addr - $remote_user [$time_local] "$request" '
               '$status $body_bytes_sent "$http_referer" '
               '"$http_user_agent" $http_x_forwarded_for';
   access_log  /home/log/mail.log mail;

   location / {
     proxy_redirect off;
     proxy_set_header Host $host;
     proxy_pass http://ghs;
     proxy_set_header  X-Real-IP  $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_redirect false;
   }
}

本文出自 小沨的天空,转载时请注明出处及相应链接。

本文永久链接: https://www.xinai.de/47001.html

发表评论

电子邮件地址不会被公开。 必填项已用*标注

You must enable javascript to see captcha here!

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

Ɣ回顶部