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