The Online Safety Act requires certain sites to verify the age of its users, usually by submitting some form of government issued ID. Age verification, which is really just a proxy for identity verification, is a highly contentious issue at the moment which strikes at the heart of the ability to freely and anonymously share ideas online. As a result, MediaLab have decided to geoblock the entire UK rather than comply with the British government’s demands.
Not being a regular, or even irregular, visitor to the site this entire state of affairs should have passed me by entirely. However, as one of the internet’s most popular image-sharing sites, Imgur has become the de facto image hosting service for many forums, message boards and even Github repositories. As a result, images embedded on such sites are unavailable to UK visitors, who are presented with a content not available in your region message instead.
Let’s see if we can unblock these images and get our internet back.
A Potential Solution #
Connecting through a VPN service in another country obscures location information, so Imgur’s geoblock doesn’t kick in any longer. However, all other websites now can’t tell I’m in the UK either. This can affect search results, suggested content on social media, online shops can direct you to the wrong store and it can flag up security alerts when logging in to certain accounts.
I am going to look into a solution that directs traffic just to certain websites through the VPN and leaves the rest of my browsing untouched.
Prerequisites #
I am starting out with a Linux machine (Raspberry Pi) with Docker installed and a VPN account with one of the most popular providers.
1. Install Gluetun via docker #
Gluetun, which describes itself as a ’thin Docker container for multiple VPN providers’, is an ideal solution to this problem. It provides a pre-configured environment which supports the most popular VPN providers and a built-in HTTP proxy server.
I began with a basic Docker compose file:
|
|
When I started the container and checked the logs I was greeted with the following:
|
|
Oops! That INFO Shutdown successful means gluetun started but wasn’t able to connect to any VPNs. Next step is to configure gluetun to work with the chosen provider.
2. Configure VPN provider #
Fortunately, gluetun comes with a set of instructions for configuring it to work with the most popular VPN providers out there. If your provider isn’t listed, there are instructions for generic OpenVPN and Wireguard connections which should support the vast majority of other providers.
After adding the configuration variables to the environment file gluetun was able to successfully connect to the VPN. I won’t post my secrets all over the internet, but here’s an example environment file to get you started:
|
|
3. Create PAC file #
What’s a PAC file? #
A proxy auto-configuration (PAC) file is a small text file that tells your browser how it should connect to the internet. Most home users connect directly to the internet through their ISP provided router or hub. Large organisations, on the other hand, use a proxy server to connect their networks to the world wide web. A proxy allows the organisation to shield its internal network from the internet, optimize bandwidth use through caching, monitor who is accessing the web and restrict access to certain sites.
Whilst it is often necessary to direct requests for internet traffic through a proxy server, there are some internal resources that can only be reached directly - a sensitive product database, company accounts, etc. This is where the PAC file comes in. It allows a network administrator to control which sites are accessed via a proxy and which can be contacted directly.
Writing the PAC file #
The PAC file consists of one Javascript function FindProxyForURL whose job it is to, you’ve guessed it, find the correct proxy for the specified URL. The return value simply indicates PROXY proxyhost:port or DIRECT to bypass the proxy server.
|
|
By directing traffic destined for imgur.com to our VPN proxy and allowing direct access for all other requests we can alter our apparent location for just that one site.
4. Host the PAC file via HTTP #
Most Chromium-based browsers will not accept a PAC file that is not served by HTTP. So we’re going to create a minimal HTTP server to serve our single PAC file.
Although software such as Apache or NGINX would be perfectly capable of handling this task, for the purpose of serving just one file I chose to utilise busybox. Busybox is a compact, single executable that provides many of the most common Unix utilities, including an HTTP server. It doesn’t have all the bells and whistles of its bigger brothers, but we’re not going to need them.
To serve the directory /var/www via port 8080 I used:
|
|
-f flag is used to keep the process in the foreground, necessary when containerizing the process.
|
|
5. Point the PC’s proxy config to your PAC file #
On Windows
- In the Settings app open Network & Internet > Proxy.
- Under Use setup script click Edit.
- Turn on Use setup script, enter the script address then select Save.
On Linux
Gnome users: #
- Open System Tools > System Settings.
- Click Network then Network Proxy.
- Choose Automatic then enter the script address.
KDE users: #
- Open System Settings > Network Settings
- Select Proxy
- Choose the Automatic method and enter the script address.
In my case, the script address is http://raspberrypi:8080/my.pac.
6. Test the setup #
Visiting imgur.com in a browser now reveals the home page. And inline images on forums, Github, etc. now display properly as well. Critically, all my other traffic is routed directly. This means my location when I shop online or access secure accounts isn’t being obscured by the VPN.
Get the code #
Addendum: Rotating the VPN server #
I have occasionally seen a too many connections error message. This appears to be Imgur routinely blocking VPN addresses. However, simply restarting the container cycles VPN servers and gluetun receives a new IP address in a different country. If this becomes a frequent problem, it might be worth cycling VPN server on a schedule (via a cron job).