简体   繁体   English

ColdFusion 代理服务器

[英]ColdFusion Proxy Server

I'm trying to create a basic proxy server so I can keep track of what my kids are doing web wise - I know there are products out there but I thought it would be an interesting exercise to write one myself.我正在尝试创建一个基本的代理服务器,以便我可以跟踪我的孩子们在网络上所做的事情 - 我知道那里有产品,但我认为自己编写一个会是一个有趣的练习。

I have the following code that kind of works but doesn't pull any images or css through - I guess because it makes another call to the remote server and gets confused我有以下代码可以正常工作,但不会通过任何图像或 css - 我猜是因为它再次调用远程服务器并感到困惑

<cfhttp url="https://www.bbc.co.uk">
    <cfhttpparam type="header" name="Proxy-Connection" value="keep-alive" >
    <cfhttpparam type="header" name="Accept" value="application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5">
    <cfhttpparam type="header" name="Accept-Language" value="en-US,en;q=0.8">
    <cfhttpparam type="header" name="Accept-Charset" value="ISO-8859-1,utf-8;q=0.7,*;q=0.3">
</cfhttp>

<cfset html = cfhttp.FileContent />
<cfoutput>#html#</cfoutput>`

What am I missing?我错过了什么?

What you want to use is the resolveurl parameter of - set it to yes/true.您要使用的是 - 将其设置为 yes/true 的 resolveurl 参数。 This defaults to no.这默认为否。

What this parameter does is resolves relative paths to absolute paths automatically for you.此参数的作用是为您自动将相对路径解析为绝对路径。

Now, if you want to change those paths as well, you would change them to also route through your http proxy script, but there won't be much use as you won't know much about the content regardless.现在,如果您也想更改这些路径,您可以将它们更改为也通过您的 http 代理脚本进行路由,但不会有太多用处,因为无论如何您都不会对内容了解太多。

resolveurl should hook you up with what you are looking for. resolveurl 应该将您与您要查找的内容联系起来。 cheers.干杯。

https://cfdocs.org/cfhttp (look for resolveurl tag attribute) https://cfdocs.org/cfhttp (查找 resolveurl 标签属性)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM