the fast, reliable localhost tunneling solution


MySQL

2011-12-27, 02:02

How to create the MySQL backend?

is it like backend=http:xxxx.pagekite.me:localhost:3306:Secret

Comments

  1. Bjarni RĂșnar Einarsson said on 2012-01-02, 12:40
    No, MySQL does not use the HTTP protocol. You could use a line like this:

    backend=raw/3306:xxxx.pagekite.me:localhost:3306:SECRET

    ... but note that you would need to use a MySQL client which can speak the HTTP Proxy protocol when connecting, as the service does not have native support for routing the MySQL protocol. What this means is that your MySQL client needs to connect to the HTTP proxy on `XXXX.pagekite.me:443` and make a CONNECT request to `XXXX.pagekite.me:3306`.

    If you are writing the client yourself, this is a simple as connecting to port 443 and sending the following string:

    CONNECT XXXX.pagekite.me:3306 HTTP/1.0\r\n\r\n

    The server will reply with:

    HTTP/1.0 200 Connection Established\r\n\r\n

    After that you can continue with the MySQL protocol over the connection as usual. This technique works for any TCP protocol.

    If you are not writing the client code yourself, you may want to give the `lapcat` tool which is included in the Debian and RPM packages a try...

    First, create a file in `/etc/lapcat/` named `_ANY_.pagekite.me`, with the following lines:

    [default]
    chain = default, httpc:%h:443

    Then invoke the mysql client like so:

    mysql -h 127.0.0.1 --port=$(lapcat --tp XXXX.pagekite.me:3306)

    What is happening here, is `lapcat` will listen on a random port and when the mysql client connects to that, it will forward the connection over the HTTP Proxy on the PageKite front-end, thus connecting the mysq client with your server. This is probably only useful for debugging, you'll need a more robust solution if you want to use this more regularly. Feel free to stop by on the IRC channel to have a chat sometime.
    Permalink
  2. Asker said on 2012-01-03, 09:25
    Thanks for your explanation. Thats mean a lot. =)
    Permalink

Leave a comment

( (Please leave these blank: )

We use Gravatar for commenter's photos. Get your own, it's free!