【发布时间】:2014-12-01 07:49:50
【问题描述】:
我有一个本地开发框,它设置了 apache2 和 catchall 通配符子域、dnsmasq 和一个本地网站。此设置便于使用多个浏览器进行测试,因为本地站点上的 Web 应用程序不允许多个浏览器从同一位置/域登录。该系统运行良好,除非我尝试测试 iframe 并在 iframe src url 中使用通配符子域。之后我得到一个找不到页面的错误。
从您可以在此页面底部查看的错误消息中包含的 URL 可以明显看出,游戏中虚拟主机的 apache 配置文件与 jsgame 中的重定向之间可能存在一些冲突,但我是不知如何解决。谁能建议如何解决这个问题?
操作系统是 Debian 6,我的系统就是这样设置的。
阿帕奇
在 etc/apache2/sites-available/game 中
<VirtualHost *:80>
ServerName catchall.game
ServerAlias *.game
VirtualDocumentRoot /var/www/%1
</VirtualHost>
#
<VirtualHost *:80>
ServerName mplayer.game
ServerAlias *.game
DocumentRoot /var/www/game/public
</VirtualHost>
网站
在 etc/apache2/sites_available/jsgame 中
Alias /jsgame/ usr/share/jsgame
RedirectMatch ^/jsgame/?$ /jsgame/example/index.html
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /JSGAME_REST http://127.0.0.1:19384/JSGAME_REST retry=1
ProxyPass /AVATAR http://127.0.0.1:19384/AVATAR retry=1
ProxyPass /UPLOAD http://127.0.0.1:19384/UPLOAD retry=1
Dnsmasq
etc/dnsmasq.conf 中的第 62 行
# Add domains which you want to force to an IP address here.
# The example below send any host in doubleclick.net to a local
# webserver.
address=/.game/127.0.0.1
index.html
通过以下方式访问 Web 应用程序:
master.game/jsgame/example/index.html?game_id=45
iframe
/jsgame/example/index.html 中的 iframe 代码
<iframe id="player0" width="25%" height="25%" src="player0.game/jsgame/pts1.html" style="position:absolute;left:0px;top:0"></iframe>
我从 iframe 收到此错误:
在此服务器上找不到请求的 URL /jsgame/example/player0.game/pts1.html。
我预计 URL 会是:
player0.game/example/pts1.html 不是如上所示。
【问题讨论】:
-
如果您改用
http://player0.game/example/pts1.html会怎样?它会避免被认为是相对的。 -
@YoannM,在您的解决方案中,究竟是什么导致 URL 被认为是相对的?
-
这本质上是一种猜测,但对于
http://,您绝对可以肯定它是绝对的。我暂时无法测试您的设置,因此无法有效地帮助您。对不起。 -
你是对的,我不知道 http:// 会有所作为。当我阅读您的解决方案时,我只认为您打算添加目录 /example 而没有添加 http://。我今天又试了一次,它奏效了。我想给你信誉。如果您发布答案,我会选择它。
标签: javascript jquery html apache dnsmasq