-
-
Save flyingnn/4174171 to your computer and use it in GitHub Desktop.
GAE Nginx proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
# The ghs.google.com server | |
server { | |
listen 80; | |
server_name www.xibu.biz; | |
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; | |
access_log off; | |
error_log off; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
FROM: http://www.xibu.biz/article_339001/%E5%85%B3%E4%BA%8Egae-ghs-nginx-%E5%8F%8D%E5%90%91%E7%9A%84%E9%85%8D%E7%BD%AE
网上有好多种配置,大同小异,大概有三种方式
前提约定:
自己的域名,如www.xibu.biz
appspot.com 二级域名,如gae-bbs.appspot.com
买VPS时给你的一个IP,如10.20.30.40
1)在域名控制面板直接设定域名 www.xibu.biz 的A记录到你的VPS主机IP,nginx可做如下配置:
可以在这里看缩进代码 https://gist.github.com/897633
这种方法是最简单的,不用在你的GAE应用的控制面板添加域名,
每个域名绑定一个对应的*.appspot.com
但要留意的是下面一行
proxy_set_header Host "gae-bbs.appspot.com";
或者改为
proxy_set_header Host "www.xibu.biz";
或
proxy_set_header Host $host;
看看你的程序有没有问题,多试几个;
如果遇到不可解决的问题就用下面一种。
2)在你的GAE应用控制面板绑定域名,如www.xibu.biz ,域名www.xibu.biz的A记录指向你VPS的IP,
nginx可做如下配置:
缩进代码参见 https://gist.github.com/897638
这个方式只需修改一行即可使用 server_name www.xibu.biz;
可添加多个域名,如 server_name www.xibu.biz www.bieminglu.com;
新添加的域名需要在GAE面板上绑定你的域名,如果没做这一步,直接把域名的A记录指向VPS IP 打开就会有404提示
3)第三种方式是做一个公共的山寨ghs,如ghs.xibu.biz 这是面向大众服务的,签于目前两个流行的山寨ghs遭遇,不推荐使用这种方式,也没有成功配置过,配置就省略了……