简体   繁体   中英

iframes wont work with wildcard catchall sub-domains and dnsmasq

I have a local development box that's setup up with apache2 and catchall wild-card sub-domains, dnsmasq and a local website. This set up is convenient for testing with multiple browsers since the web application on the local site doesn't allow multiple browsers to log in from the same location/domain. This system works well except when I tried testing iframes and using wild-card sub-domains within the iframes src url. After which I get a page not found error.

As evident from the URL contained within the error message that you can view at the bottom of this page, it seems that there may be some conflict between apache configuration files for virtual hosts in game and the redirect in jsgame but I'm at a loss at how to fix it. Can anyone suggest how to fix resolve this problem?

The OS is Debian 6 and this is how my system is set up.

Apache

Within 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>

Website

Within 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

line 62 within etc/dnsmasq.conf

# 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

The web application is accessed via:

master.game/jsgame/example/index.html?game_id=45

iframe

iframe code within /jsgame/example/index.html

<iframe id="player0" width="25%" height="25%" src="player0.game/jsgame/pts1.html" style="position:absolute;left:0px;top:0"></iframe>

I get this error from the iframe:

The requested URL /jsgame/example/player0.game/pts1.html was not found on this server.

I expected that the URL would be:

player0.game/example/pts1.html not as shown above.

What if you use http://player0.game/jsgame/pts1.html instead of player0.game/jsgame/pts1.html as the src attribute of your iframe?

<iframe 
   id="player0" 
   width="25%" 
   height="25%" 
   src="http://player0.game/jsgame/pts1.html" 
   style="position:absolute;left:0px;top:0">
</iframe>

It would avoid being considered relative.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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