预览
下载Releases
img
下载Raw
img
打包下载代码
img
下载项目中的文件
img

Nginx配置

server {
    listen 80;
    listen [::]:80;
    # 替换为你的域名
    server_name gh.wuxie.de;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    # 替换为你的域名
    server_name gh.wuxie.de;
    # 替换为你的证书路径
    ssl_certificate /root/www/ssl/wuxie.crt;
    ssl_certificate_key /root/www/ssl/wuxie.key;

    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    add_header Strict-Transport-Security "max-age=31536000";

    # 增加代理缓冲区大小
    proxy_buffer_size 16k;
    proxy_buffers 8 16k;
    proxy_busy_buffers_size 24k;

    # 增加客户端请求头缓冲区大小
    large_client_header_buffers 4 16k;

    location = /github-proxy {
        return 404;
    }

    location = /github-proxy/ {
        return 404;
    }


    location = /github-proxy/login {
        return 404;
    }

    location = /github-proxy/signup {
        return 404;
    }

    location ~ ^/github-proxy/(https:.*)$ {
        set $url_path $1;

        if ($url_path ~ "^https:/github\.com/(.*)$") {
            return 301 /github-proxy/$1;
        }

        if ($url_path ~ "^https:/raw\.githubusercontent\.com/(.*)$") {
            return 301 /github-proxy/raw/$1;
        }

        if ($url_path ~ "^https:/objects\.githubusercontent\.com/(.*)$") {
            return 301 /github-proxy/objects/$1;
        }

        if ($url_path ~ "^https:/codeload\.github\.com/(.*)$") {
            return 301 /github-proxy/codeload/$1;
        }
        add_header X-Debug-Rul $url_path always;
        return 400;
    }

    # 处理 raw.githubusercontent.com 的代理请求
    location ^~ /github-proxy/raw/ {
        proxy_pass https://raw.githubusercontent.com/;
        proxy_set_header Host raw.githubusercontent.com;
        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 $scheme;
        proxy_http_version 1.1;
        sub_filter_once off;
    }

    # 处理 objects.githubusercontent.com 的代理请求
    location ^~ /github-proxy/objects/ {
        proxy_pass https://objects.githubusercontent.com/;
        proxy_set_header Host objects.githubusercontent.com;
        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 $scheme;
        proxy_http_version 1.1;
        sub_filter_once off;
    }

    # 处理 codeload.github.com 的代理请求
    location ^~ /github-proxy/codeload/ {
        proxy_pass https://codeload.github.com/;
        proxy_set_header Host codeload.github.com;
        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 $scheme;
        proxy_http_version 1.1;
        sub_filter_once off;
    }

    # 处理 github.com 的代理请求
    location /github-proxy/ {
        proxy_pass https://github.com/;
        proxy_set_header Host github.com;
        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 $scheme;
        proxy_cookie_domain github.com $server_name;
        proxy_http_version 1.1;

        sub_filter_once off;

        sub_filter "\"https://github.com" "\"https://$server_name/github-proxy";
        sub_filter "\"https://raw.githubusercontent.com" "\"https://$server_name/github-proxy/raw";
        sub_filter "\"https://objects.githubusercontent.com" "\"https://$server_name/github-proxy/objects";
        sub_filter "\"https://codeload.github.com" "\"https://$server_name/github-proxy/codeload";

        proxy_redirect https://github.com https://$server_name/github-proxy;
        proxy_redirect https://raw.githubusercontent.com https://$server_name/github-proxy/raw;
        proxy_redirect https://objects.githubusercontent.com https://$server_name/github-proxy/objects;
        proxy_redirect https://codeload.github.com https://$server_name/github-proxy/codeload;

    }
}

在/etc/nginx/conf.d/下新建一个conf文件
示例:

nano /etc/nginx/conf.d/gh.conf

复制代码,修改域名
保存退出,刷新配置

nginx -s reload

用法
在你的域名/github-proxy后面加github复制的链接

gh.wuxie.de/github-proxy/https://github.com/XTLS/Xray-core/releases/download/v25.3.6/Xray-linux-64.zip
文章作者: 子受
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 薪萤-博客
技术
喜欢就支持一下吧
打赏
微信 微信
支付宝 支付宝