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; } }
文章评论