Skip to content

Instantly share code, notes, and snippets.

@lostsnow
Created February 1, 2015 07:07
Show Gist options
  • Save lostsnow/c7d2fbaa5398ab871a80 to your computer and use it in GitHub Desktop.
Save lostsnow/c7d2fbaa5398ab871a80 to your computer and use it in GitHub Desktop.
nginx proxy for mirrors (rubygems, pypi, github, etc.)
server {
listen 80;
server_name rubygems.org production.cf.rubygems.org production.s3.rubygems.org;
keepalive_timeout 65;
location / {
resolver 114.114.114.114;
proxy_pass http://$host;
### force timeouts if one of backend is died ##
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
}
access_log /opt/weblogs/proxy-access.log access;
}
server {
listen 443;
server_name rubygems.org
github.com
pypi.python.org;
keepalive_timeout 65;
ssl on;
ssl_certificate ssl/proxy-mirror.crt;
ssl_certificate_key ssl/proxy-mirror.key;
ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
location / {
resolver 114.114.114.114;
proxy_pass https://$host;
### force timeouts if one of backend is died ##
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
}
access_log /opt/weblogs/proxy-access.log access;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment