原文参照
https://gist.github.com/1216602
——————————————————
# 在本地服务器建立 rubygems.org 的镜像缓存,以提高 gem 的安装速度# 此配置设置缓存过期为1天,也就是说,新上的 gem 无法马上安装# 做这个起什么作用?# rubygems 的很多资源文件是存放到 Amazon S3 上面的,由于 GFW 对某些 S3 服务器又连接重置或丢包,导致 gem 安装异常缓慢或有时候根本无法连接安装。# 而通过这种跳板的方式可以很好的解决这个问题,当然前提是 Nginx反向代理 服务器需要在国外proxy_cache_path /var/cache/rubygems levels=1:2 keys_zone=RUBYGEMS:10minactive=24h max_size=1g;server {listen 80;server_name rubygems.org;location / {proxy_pass http://rubygems.org;proxy_redirect off;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}}server {listen 80;server_name production.cf.rubygems.org;location / {proxy_pass http://production.cf.rubygems.org;proxy_redirect off;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_cache RUBYGEMS;proxy_cache_valid 200 1d;proxy_cache_use_stale error timeout invalid_header updatinghttp_500 http_502 http_503 http_504;}}server {listen 80;server_name production.s3.rubygems.org;location / {proxy_pass http://production.s3.rubygems.org;proxy_redirect off;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_cache RUBYGEMS;proxy_cache_valid 200 1d;proxy_cache_use_stale error timeout invalid_header updatinghttp_500 http_502 http_503 http_504;}}server {listen 443;server_name rubygems.org;location / {proxy_pass https://rubygems.org;proxy_redirect off;proxy_set_header Host $http_host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;}ssl on;ssl_certificate /etc/nginx/conf/server.crt;ssl_certificate_key /etc/nginx/conf/server.key;ssl_session_timeout 5m;ssl_protocols SSLv2 SSLv3 TLSv1;ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;ssl_prefer_server_ciphers on;}50.93.202.* rubygems.org50.93.202.* production.cf.rubygems.org50.93.202.* production.s3.rubygems.org#生成SSl证书, 这个是在centos下的情况 #openssl genrsa -out server.key 2048 #openssl req -new -x509 -key server.key -out server.crt -days 1095