公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

每次从github上拉东西,速度都奇慢无比,本地的时候可以设置代理,但是一些特殊场合并不是特别方便,所以就写了下面的反向代理。

建议直接看这个

  • https://ghostcir.com/s/169.html,通过一个域名加速各种网站

设置upstream(上游),ip地址可以通过dig github.com获取,或者比较懒的,直接server github.com:443,它会自动解析。

upstream github {
    server 192.30.253.112:443;
    server 192.30.253.113:443;
    keepalive 16;#设置连接池加快访问速度。
}

Nginx

配置https,也可以直接使用http,将listen 443 ssl http2 reuseport;替换成listen 80;就可以。

server
{
    listen 443 ssl http2 reuseport;

    ssl_certificate ssl/p.ghostcir.com.pem;
    ssl_certificate_key ssl/p.ghostcir.com.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_session_timeout      1d;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;

    ssl_session_cache        shared:SSL:50m;

    ssl_session_tickets      on;

    ssl_stapling             on;

    server_name p.ghostcir.com; #绑定的域名

nginx

屏蔽搜索引擎

    if ($http_user_agent ~* "qihoobot|Baiduspider|googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot") #防止搜索引擎收录
    {
        return 403;
    }

nginx

配置反向代理

    location / {
        proxy_set_header Accept-Encoding ""; #不使用压缩,如gzip
        proxy_set_header Connection "";
        proxy_http_version 1.1; #使用http1.1长连接
        proxy_connect_timeout    10s; #设置连接超时
        proxy_read_timeout       10s; #设置读取超时
        proxy_set_header Host github.com;
        proxy_hide_header Strict-Transport-Security; #隐藏协议头,避免因为反向代理开启hsts
        proxy_pass https://github;
    }
}

nginx

最后贴一下完整规则

upstream github {
    server 192.30.253.112:443;
    server 192.30.253.113:443;
}

server
{
    listen 443 ssl http2 reuseport;

    ssl_certificate ssl/p.ghostcir.com.pem;
    ssl_certificate_key ssl/p.ghostcir.com.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_session_timeout      1d;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+ECDSA+AES128:EECDH+aRSA+AES128:RSA+AES128:EECDH+ECDSA+AES256:EECDH+aRSA+AES256:RSA+AES256:EECDH+ECDSA+3DES:EECDH+aRSA+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;

    ssl_session_cache        shared:SSL:50m;

    ssl_session_tickets      on;

    ssl_stapling             on;

    server_name p.ghostcir.com; #绑定的域名

    if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot") #防止搜索引擎收录
    {
        return 403;
    }

    location / {
        proxy_set_header Accept-Encoding "";
        proxy_set_header Connection "";
        proxy_http_version 1.1;
        proxy_connect_timeout    10s;
        proxy_read_timeout       10s;
        proxy_set_header Host github.com;

        proxy_hide_header Strict-Transport-Security; #隐藏协议头,避免因为反向代理开启hsts

        proxy_pass https://github;
    }
}

分享到:
标签:代理 nginx
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定