前些天临时写的一脚本级反向代理程序,用法很简单,设置好目标站地址,然后放到你网站根目录:index.asp,再将404页面自定义为:index.asp,即可。
由于暂时没有 url 替换需要,所以没有写 url 替换规则,如果你有需要的话,可以在末尾写个函数替换 http.ResponseBody 中的内容。
<% '************************************************** 'Asp反向代理程序,调用远程站点全站数据,脚本级反向代理,一款脚本级反向代理程序 'By: Nuclear'Atk, https://lcx.cc/ 'Created: 2014-03-27 19:30:56 'Last Update: 2014-3-28 11:10:56 '************************************************** 'On Error Resume Next Server.ScriptTimeout = 300 '---------- '组合Url地址 Dim url If Instr(Request.QueryString, "404;http://") > 0 Then '提取参数 url = Mid(Request.QueryString, Len("404;http://" & Request.ServerVariables("HTTP_HOST") & ":" & Request.ServerVariables("Server_Port") & "/") + 1) Else If Request.QueryString <> "" Then url = "?" & Request.QueryString End IF End IF url = "https://lcx.cc/" & url '完整地址 '---------- '获取远程数据 Dim http Set http = Server.CreateObject("WinHttp.WinHttpRequest.5.1") http.Open "GET", url, False If Request.ServerVariables("HTTP_REFERER") <> "" then http.SetRequestHeader "Referer", Request.ServerVariables("HTTP_REFERER") End IF If Request.Cookies <> "" then http.SetRequestHeader "Cookie", Request.Cookies End IF http.SetRequestHeader "User-Agent", Request.ServerVariables("HTTP_USER_AGENT") http.SetRequestHeader "X-Forwarded-For", Request.ServerVariables("REMOTE_ADDR") & ", " & Request.ServerVariables("LOCAL_ADDR") http.SetRequestHeader "Connection", "Close" http.SetRequestHeader "Nuclear-Atk", "http://" & Request.ServerVariables("HTTP_HOST") & Request.ServerVariables("SCRIPT_NAME") & "?" & Request.QueryString http.SetRequestHeader "Nuclear-Atk-Host", Request.ServerVariables("HTTP_HOST") http.Send Response.Status = http.Status & " " & http.StatusText '照搬远程HTTP状态码与状态描述文本 Response.ContentType = http.GetResponseHeader("Content-Type") '照搬远程内容类型 Response.BinaryWrite http.ResponseBody '输出二进制内容 %>
留言评论(旧系统):