Skip to content

January 13, 2014


Using Tinyproxy for Mobile Development on OS X

A common problem encountered with web development where private or local development sites with no public DNS sites are being used is the one of viewing these locally running development sites on an iPhone or iPad for testing purposes. This becomes even more of a problem when working on a mobile theme or particularly a responsive design where it’s kind of important to test simultaneously on multiple screen sizes while your implementing the breakpoints required for the content to adapt to the different displays.

For the last few weeks I’ve been working on a large scale responsive project with a team of other awesome Classy Llama’s. So this got me to thinking, and the result was: eureka, I’ll run a proxy server!

There are many proxy servers out there which would likely do just as good a job at accomplishing the same goals. I chose Tinyproxy because it’s a very lightweight proxy daemon built specifically for POSIX operating systems, meaning it will run seamlessly on the OS X development machines we primarily use, but can also be readily used on Linux if needed. It’s fast and very lean on resource utilization. It’s also freely distributed under the GNU GPL v2 license, so the cost certainly fits the bill here as well.

If you need a proxy with more advanced features, you may find Charles Proxy will serve you better. If I ever give it a go, I may come back with another blog post, but for now I’ve not tried it. One thing it has is traffic limiting to simulate network conditions, but my iOS devices have that ability built-in.

I use the Homebrew package manager to install the majority of my CLI tools which I use on a daily basis. Fortunately, there is a pre-existing package for installing Tinyproxy with Homebrew. So it’s a snap to setup! Here is how…

  1. Run the one line install command. Your output may vary slightly.

    $ brew install tinyproxy
    ==> Downloading
    Already downloaded: /Library/Caches/Homebrew/tinyproxy-1.8.3.tar.bz2
    ==> Downloading patches
    ######################################################################## 100.0%
    ==> Patching
    patching file configure
    Hunk #1 succeeded at 6744 (offset -1 lines).
    ==> ./configure --prefix=/usr/local/Cellar/tinyproxy/1.8.3 --disable-regexcheck
    ==> make install
    /usr/local/Cellar/tinyproxy/1.8.3: 14 files, 244K, built in 44 seconds
  2. Next, for this to be useful to you, you’ll need to allow other devices on your network access to your proxy server. I’ve added localhost and the local class C subnet to my allow list, but it’s possible to specify hostnames of connecting devices as well. It’s hardly very secure if you’re running on a public network, so keep this in mind if you frequently work from Starbucks.

    $ cd /usr/local/Cellar/tinyproxy/1.8.3/
    $ perl -i.bak -pe 's/^Allow$/Allow\nAllow localhost\nAllow\/24/' ./etc/tinyproxy.conf
  3. The one thing the brew package missed was creating two directories which tinyproxy needs to run. Launch it in non-daemon mode and it will tell you what these are, allowing you to create them.

    $ tinyproxy -d
    tinyproxy: Could not create file /usr/local/Cellar/tinyproxy/1.8.3/var/log/tinyproxy/tinyproxy.log: No such file or directory
    tinyproxy: Could not create file /usr/local/Cellar/tinyproxy/1.8.3/var/run/tinyproxy/ No such file or directory
    tinyproxy: Could not create PID file.
    $ mkdir -p ./var/log/tinyproxy/ ./var/run/tinyproxy/
  4. And finally, launch your proxy in the background like so. It’ll spawn a few threads to handle incoming connections and start working immediately.

    $ tinyproxy

Ok, so the proxy is up and running, but how can we use it? Not to worry, you’re almost there! The last thing you need to do is configure your iOS device’s proxy settings so it will route all http traffic through the proxy.

  1. Launch the Settings app and open the WiFi section.WiFi Settings
  2. Click the information button to edit the advanced settings.Advanced iOS WiFi Settings
  3. Set the hostname or private IP address of the machine running the proxy and port number under HTTP Proxy -> Manual, all the way at the bottom of the screen.Manual HTTP Proxy Settings
Read more from Development
3 Comments Post a comment
  1. Jan 14 2014

    David – Thanks for sharing! I have long wanted to be able to do this, so it’s great to have such a simple solution to accomplish this.

  2. Riky
    Jun 25 2014

    Hi David. Good read. Does tinyproxy have a frontend or something – much like from Websecurify.While I understand it is free it fills it is a bit of pain to setup and work with.

  3. dalger
    Jun 27 2014

    Hi Riky- Thanks for commenting… I believe there may be some GUI management tools provided for it by another 3rd party, but I have never used them and don’t know what they are off-hand. Since TinyProxy is meant to be a super light-weight proxy daemon, it does not come with a GUI configuration tool.


Share your thoughts, post a comment.


Note: HTML is allowed. Your email address will never be published.

Subscribe to comments