Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Friday, July 27, 2012

http: couple of ways to forward http requests


if you have a domain name that points to an ip and you want to serve another page...

if hosted on a different machine which also has a public ip, you can easily redirect requests by javascript's window.location
ex.
<script language="JavaScript">window.location="http://x.x.x.x";</script>

or encapsulate the page in an html frame
ex.
<frameset frameborder="NO" cols="100%,*" rows="*" border="0" framespacing="0">
                <frame name="topFrame" scrolling="auto" src="http://x.x.x.x" />
</frameset>


if hosted on a different machine which has no public ip, you can do port forwarding using your firewall
ex.
in iptables forwarding public ip x.x.x.x port 81 to local ip y.y.y.y port 80:
-A PREROUTING -d x.x.x.x -p tcp --dport 81 -j DNAT --to y.y.y.y:80
-A POSTROUTING -d y.y.y.y -p tcp --dport 80 -j SNAT --to x.x.x.x:81


or if you want to serve another domain on the same machine, you can use apache's virtual host
ex.
NameVirtualHost *:80
<VirtualHost *:80>
        ServerName alternate.mydomain.ph
        DocumentRoot /usr/local/apache2/htdocs/alternate
</VirtualHost>

Thursday, October 13, 2011

javascript: iframe cross site script

given a parent page with an iframe-contained child page... from the child page, you can readily call a javascript function on the parent page IF both parent and child pages are on the same server.

now, WHAT IF your iframe-contained child page is a page residing on another server?

here's what you can do:
1. know the domain your parent frame holder is using (ex. www.xxx.ph)
2. point a subdomain to the server hosting your child page (ex. child.xxx.ph)
3. set domain in javascript for both parent and child page
 <script>document.domain="xxx.ph"</script>

now you can call your javascript function in your parent page from the iframe-contained child residing on another server!

;)

check out http://www.cybersoft.ph/testIFrame/iframeParent.html

Tuesday, August 02, 2011

SSH : No matching host key type found. Their offer: ssh-rsa,ssh-dss

Got this while connecting to my mikrotik router via ssh   Unable to negotiate with <ip address> port <ssh port>: no matching hos...