About

mFabrik Blog is about mobile and web software development, open source and Linux. We tell exciting tales where business, technology, web and mobile convergence.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License.

Testing localhost site in Opera Mini – SSH tunnel trick

Opera Mini has 100 million users around the world – in developing countries it’s a very important browser. Opera Mini is based on thin client model where the page is rendered on the server and then send as compressed to the mobile. Some Javascript / AJAX support is available, especially if it run during or before document ready handler.

Opera provides web based simulator which you can use to test your web pages in Opera Mini. Opera Mini is based on Java, on both mobile and in the simulator, so Java plug-in is needed.

If you don’t have an public IP address you are firewalled you need to do a port forward with SSH tunnel though a server having public IP:

ssh -gNR 8888:localhost:8888 yourserver.com

Then you just go to Opera Mini simulator and type your port forwarded address:

yourserver.com:8888

 

Get developers  Subscribe mFabrik blog in a reader Follow me on Twitter

MySQL bind_address workaround

MySQL has an ugly design fault preventing it to listen more than one interface in its bind_address my.conf directive. Thus, you usually cannot connect to the same MySQL instance using localhost and external IP sources.

Here is a workaround based on xinetd daemon. These are sample commands for Ubuntu/Debian.

Go to root

sudo -i

Install xinetd

apt-get install xinetd

Add a new xinetd mapping

pico /etc/xinetd.d/mysql

service mysql
{
    only_from	   = localhost mansikki.redinnovation.com 80.75.108.108 server213-171-218-5.livedns.org.uk 213.171.218.5
    flags          = REUSE
    socket_type    = stream
    wait           = no
    user           = root
    redirect       = 127.0.0.1 3306
    log_on_failure += USERID
    interface 	   = 84.34.147.68
}

Restart xinetd

/etc/init.d/xinetd restart

To debug xinetd:

/etc/init.d/xinetd stop
xinetd -d

xinetd only_from directive also gives an access control by allowed source IP addresses. This protects your MySQL against bots and brute force attacks.

Note that iptables DNAT translation doesn’t work (easily). Localhost packets don’t travel PREROUTING and POSTROUTING chains.