Last active
January 4, 2025 12:51
-
-
Save wuuconix/31d3040db38dcaa3fb956c18aa809cc7 to your computer and use it in GitHub Desktop.
适用nginx反代任意网站
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resolver 8.8.8.8; | |
map $request_uri $custom_referer { | |
default $http_referer; | |
"~i\.pximg\.net" https://i.pximg.net/; | |
"~sinaimg\.cn" https://m.weibo.cn/; | |
} | |
server | |
{ | |
listen 443 ssl;# https 监听的是 443端口 | |
server_name proxy.wuuconix.link; | |
keepalive_timeout 100; | |
ssl_session_cache shared:SSL:10m; | |
ssl_session_timeout 10m; | |
ssl_certificate /etc/nginx/any.wuuconix.link/cert.pem; # 证书路径 | |
ssl_certificate_key /etc/nginx/any.wuuconix.link/key.pem; # 请求认证 key 的路径 | |
ssl_protocols TLSv1.1 TLSv1.2; | |
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; | |
ssl_prefer_server_ciphers on; | |
ssl_session_cache shared:SSL:10m; | |
add_header Access-Control-Allow-Origin *; | |
add_header Access-Control-Allow-Headers *; | |
location ~* /http.* { | |
rewrite /(https?://?)(.*) /$2 permanent; | |
} | |
location ~* /([^/]*)/ { | |
set $foo $1; | |
proxy_set_header Referer $custom_referer; | |
proxy_buffer_size 128k; | |
proxy_buffers 16 32k; | |
proxy_busy_buffers_size 128k; | |
if ( $http_referer ~* .+/([^/]*)/$) { | |
return 200 $foo; | |
proxy_pass https://$1; | |
} | |
if ( $http_referer = '' ) { | |
#return 200 $foo; | |
rewrite /[^/]*/(.*) /$1 break; | |
proxy_pass https://$foo; | |
} | |
} | |
location ~* /([^/]*) { | |
rewrite /([^/]*) /$1/ permanent; | |
} | |
} | |
server | |
{ | |
listen 80; | |
server_name proxy.wuuconix.link; | |
rewrite ^(.*) https://$server_name$1 permanent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment