0
我试图用自己的笔记本电脑模拟相同的原产地策略用于研究目的。 我会尝试以下方法,但它不工作:在一个工作站中模拟同源策略
httpd.conf中:现在
...
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.client.es
DocumentRoot "C:/maestro/desarrollo/Apache Software Foundation/Apache2.2/htdocs/client"
<Directory "C:/maestro/desarrollo/Apache Software Foundation/Apache2.2/htdocs/client">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.custom.es
DocumentRoot "C:/maestro/desarrollo/Apache Software Foundation/Apache2.2/htdocs/custom"
<Directory "C:/maestro/desarrollo/Apache Software Foundation/Apache2.2/htdocs/custom">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
...
,为了获得SOP效果我建了两个不同的模拟网站:
WWW .client.es/index.htm的
...
<html>
...
<script type="text/javascript" src="http://www.custom.es/js/hello.js"></script>
...
</body>
</html>
www.custom.es/js/hello.js
alert("Hello.js: loaded");
最后我加入了适当的行etc/hosts文件
127.0.0.1 www.custom.es
127.0.0.1 www.client.es
所以我可以从浏览器中得到不同mocksites,好像他们是真正的不同部位。
问题是我期待Chrome/Firefox /资源管理器/ etc 不能使得到hello.js由于相同的原产地政策,但一切都服务,并没有错误时,我浏览到www。 client.es/index.htm
任何线索?提前致谢。
好的,非常感谢。我认为这可能很简单,但它听起来有点奇怪,因为接受外部脚本至少和执行远程ajax调用一样危险。你不觉得吗? – 2011-03-24 09:38:59