基于 xampp/wamp 的 Apache 服务器自定义回复
如何在连接到特定端口时根据基于 xampp/wamp 的 Apache 服务器上的自定义请求发送自定义响应?
我正在尝试回复 Flash 应用程序请求的 \0 以允许跨域 http GET 请求。
默认情况下,闪存策略请求是向端口 843 发出的,我希望保持这种状态。
端口应该得到一个\0(以空字符结尾,\0仅供参考)并回复类似以下内容:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-http-request-headers-from domain="*" headers="*" secure="true" />
<allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>
据我所知,请求应该以纯文本形式返回,尽管内容类型可能会也被需要。
我尝试使用以下内容: http://socketpolicyserver.com/ 虽然它监听端口并接受连接,它不会根据请求回复指定的 xml。
迈克,任何获得正确答复的方法/途径将不胜
感激
。
!---更新--->
我编写了一个简单的 C# Web 服务器,它监听端口 843,并提供上述策略 - 它运行得很好,但是,当使用 SecureSocket 连接进行安全连接时(即打开 HTTPS/SSL 协议的套接字) -发送的请求使用主机证书进行加密。据我所知,没有办法通过外部应用程序监听或获取服务器证书并解密数据,因此,唯一的方法是以某种方式“教导”Apache 在通过适当的端口。
我的另一个想法是读取存储在 Apache 目录中的服务器的证书文件,而不管服务器本身发生什么,尽管在我看来这是一种矫枉过正。
很想听听你的意见,
迈克。
How can I send a custom response upon a custom request on a xampp/wamp based Apache server upon a connection to a specific port?
I'm trying to reply to the \0 a flash app is requesting in order to allow a crossdomain http GET request.
The flash policy request, is made to port 843 by default and i'd like to keep it that way.
The port should get a \0 (ending with a null char,\0 is just for the reference) and replying with something like:
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<site-control permitted-cross-domain-policies="master-only"/>
<allow-http-request-headers-from domain="*" headers="*" secure="true" />
<allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>
As far as i know, the request should be return as a plain text, although Content-type, might be needed as well.
I've tried using the following: http://socketpolicyserver.com/ and although it listens to the port and accepts connections, it doesn't reply with the specified xml upon request.
Any methods / ways of achieving a proper reply will be appreciated,
with regards,
Mike.
!---UPDATE--->
I wrote a simple C# web server which listens to port 843, and serves the aforementioned policy - it worked out just fine, however, when using a SecureSocket connection for a secure connection (i.e opening a socket to a HTTPS/SSL protocol) - the request that is sent is encrypted using the hosts certificate. As far as i know, there's no way of listening or acquiring the servers certificate and decrypting the data via an external app hence, the only way is to somehow 'teach' Apache to respond with the crossdomain policy after a proper request is sent via an appropriate port.
Another idea i have is to read the server's certificate file stored in the Apache directory regardless of what happens on the server itself, though imo it's an overkill.
Would love to hear your comments,
Mike.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以这就是我最终解决它的方法:
我使用了这些人的代码并进行了一些修改: http://www.switchonthecode.com/tutorials/csharp-tutorial-simple-threaded-tcp-server
并创建了一个监听端口的简单多线程 Web 服务器843,并根据适当的闪存请求提供了一些通用的策略。
Adobe 提供了几个示例,但由于某种原因,Windows 不喜欢这些示例。
另请注意,如果您使用 Flash 的 SecureSocket 对象,据称它应该使用目标服务器(IIS'/Apaches'/Tomcats' 等)SSL 凭据,并将使用目标服务器证书的公钥启动客户端身份验证,话又说回来,可能不是这样,所以这段代码没有 SSL 支持,尽管我已经开始使用 C# 的 SSL Streams 实现一个,但到目前为止还没有任何运气。如果您可以通过 SSL 使其工作,请告诉我。
希望这段代码能有所帮助,
迈克。
So here's how i eventually solved it:
I've used this guys code with some modifications: http://www.switchonthecode.com/tutorials/csharp-tutorial-simple-threaded-tcp-server
and created a simple multithreaded web server that listens to port 843, and provides a somewhat general policy upon the appropriate flash request.
There were several examples provided by Adobe, but for some reason, windows didn't like those.
Also note that if you're using the SecureSocket object of flash it should allegedly use the target servers (IIS'/Apaches'/Tomcats' etc..) SSL credentials and will initiate a client Authentication using the public key of the target servers certificate, then again, it might not so this code doesn't have SSL support, although i've started implementing one using C#'s SSL Streams, so far without any luck. If you can make it work via SSL, please let me know.
Hope this code will help,
Mike.