openshift 设置 nginx 代理google
1. 创建DIY app
env 查看环境变量,后面会用到
cd $OPENSHIFT_DATA_DIR
后面我会介绍如何在openshift上安装nginx,当然网上也有,你可以搜哈
2.编译nginx
这里用到了pcre-8.35,ngx_cache_purge-2.1 这些模块,请自行下载
make clean
./configure --prefix=$OPENSHIFT_DATA_DIR --with-pcre=$OPENSHIFT_TMP_DIR/pcre-8.35 \
--with-http_sub_module --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module \
--with-http_sub_module --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module \
--with-http_gzip_static_module --add-module=$OPENSHIFT_TMP_DIR/ngx_cache_purge-2.1
make install
3.配置nginx
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
port_in_redirect off;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#A
#gzip on;
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 $OPENSHIFT_DIY_IP:$OPENSHIFT_DIY_PORT;
server_name localhost;
#server_name google-i51.rhcloud.com;
#rewrite ^(.*) https://xxx.xxx.com$1 permanent;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
# root html;
# index index.html index.htm;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
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 xxx.xxx.com;
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 xxx.xxx.com
#sub_filter_once off;
}
}
} ok,访问你在 rhcloud.com地址,看哈是否成功,当然中间可能有错误,可以看哈log文件,找哈原因 上面的 xxx.xxx.com 实际上是xxx.rhcloud.com,要替换你自己的哈
祝你成功,google在手
,欢迎抛砖哈
最后欢迎访问我的小站,利多乐