学校禁止了frp协议,所以要用这个类似的工具进行穿透 [rapiz1/rathole: A lightweight and high-performance reverse proxy for NAT traversal, written in Rust. An alternative to frp and ngrok. (github.com)](https://github.com/rapiz1/rathole/) 使用香港vps获得了更低的延迟 客户端配置client.toml ``` [client] remote_addr = "ip:9000" # 服务器的地址。端口必须与 `server.bind_addr` 中的端口相同。 [client.services.dorm_web_http] token = "xxx" # 必须与服务器相同以通过验证 local_addr = "127.0.0.1:80" # 需要被转发的服务的地址 [client.services.dorm_web_https] token = "xxx" # 必须与服务器相同以通过验证 local_addr = "127.0.0.1:443" # 需要被转发的服务的地址 ``` 服务端配置server.toml ``` [server] bind_addr = "0.0.0.0:9000" # `9000` 配置了服务端监听客户端连接的端口 [server.services.dorm_web_http] token = "xxx" # 用于验证的 token bind_addr = "0.0.0.0:9001" [server.services.dorm_web_https] token = "xxx" # 用于验证的 token bind_addr = "0.0.0.0:9002" ``` 然后服务端使用下面的反向代理配置,替换dorm为dt,代表外网的域名,不知道为什么代理9002的https会302跳转回dorm内网域名,所以暂时改用9001的http代理,可以正常使用() 反向代理配置文件 ``` #PROXY-START/ location ^~ / { if ($host ~* ^(.*?)\.dt\.skyw\.cc$) { set $hosts $1.dorm.skyw.cc; } proxy_ssl_verify off; proxy_pass http://localhost:9001; proxy_set_header Host $hosts; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_http_version 1.1; # proxy_hide_header Upgrade; add_header X-Cache $upstream_cache_status; if ($uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$") { expires 1m; } proxy_ignore_headers Set-Cookie Cache-Control expires; proxy_cache cache_one; proxy_cache_key $host$uri$is_args$args; proxy_cache_valid 200 304 301 302 1m; sub_filter 'dt.skyw.cc' 'dorm.skyw.cc'; sub_filter_once off; sub_filter_types *; } #PROXY-END/ ``` Loading... 学校禁止了frp协议,所以要用这个类似的工具进行穿透 [rapiz1/rathole: A lightweight and high-performance reverse proxy for NAT traversal, written in Rust. An alternative to frp and ngrok. (github.com)](https://github.com/rapiz1/rathole/) 使用香港vps获得了更低的延迟 客户端配置client.toml ``` [client] remote_addr = "ip:9000" # 服务器的地址。端口必须与 `server.bind_addr` 中的端口相同。 [client.services.dorm_web_http] token = "xxx" # 必须与服务器相同以通过验证 local_addr = "127.0.0.1:80" # 需要被转发的服务的地址 [client.services.dorm_web_https] token = "xxx" # 必须与服务器相同以通过验证 local_addr = "127.0.0.1:443" # 需要被转发的服务的地址 ``` 服务端配置server.toml ``` [server] bind_addr = "0.0.0.0:9000" # `9000` 配置了服务端监听客户端连接的端口 [server.services.dorm_web_http] token = "xxx" # 用于验证的 token bind_addr = "0.0.0.0:9001" [server.services.dorm_web_https] token = "xxx" # 用于验证的 token bind_addr = "0.0.0.0:9002" ``` 然后服务端使用下面的反向代理配置,替换dorm为dt,代表外网的域名,不知道为什么代理9002的https会302跳转回dorm内网域名,所以暂时改用9001的http代理,可以正常使用() 反向代理配置文件 ``` #PROXY-START/ location ^~ / { if ($host ~* ^(.*?)\.dt\.skyw\.cc$) { set $hosts $1.dorm.skyw.cc; } proxy_ssl_verify off; proxy_pass http://localhost:9001; proxy_set_header Host $hosts; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_http_version 1.1; # proxy_hide_header Upgrade; add_header X-Cache $upstream_cache_status; if ($uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$") { expires 1m; } proxy_ignore_headers Set-Cookie Cache-Control expires; proxy_cache cache_one; proxy_cache_key $host$uri$is_args$args; proxy_cache_valid 200 304 301 302 1m; sub_filter 'dt.skyw.cc' 'dorm.skyw.cc'; sub_filter_once off; sub_filter_types *; } #PROXY-END/ ``` Last modification:October 28, 2024 © Allow specification reprint Like 如果觉得我的文章对你有用,请随意赞赏