Skip to main content
Bypassing Imgur UK Block
  1. Home/
  2. Blog/

Bypassing Imgur UK Block

·1387 words·7 mins
It has recently come to my attention that Imgur, the free image hosting platform, has blocked UK residents from accessing its website. It appears their parent company, MediaLab have had a spat with the UK government’s Information Commissioner’s Office (ICO) about how they have chosen to handle the Online Safety Act.

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.

Content not available message
Imgur’s geoblock has broken many online images.

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
services:
  gluetun:
    image: qmcgaw/gluetun
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    ports:
      - 8888:8888/tcp
    volumes:
      - /var/cache/gluetun:/gluetun
    env_file: .env

When I started the container and checked the logs I was greeted with the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
gluetun  | ========================================
gluetun  | =============== gluetun ================
gluetun  | ========================================
gluetun  | ========================================
gluetun  | =========== Made with ❤️ by ============
gluetun  | ======= https://github.com/qdm12 =======
gluetun  | ========================================
gluetun  | ========================================
gluetun  |
gluetun  | Running version latest built on 2025-11-19T16:15:49.538Z (commit 9f39d47)
gluetun  |
gluetun  | 🔧 Need help? ☕ Discussion? https://github.com/qdm12/gluetun/discussions/new/choose
gluetun  | 🐛 Bug? ✨ New feature? https://github.com/qdm12/gluetun/issues/new/choose
gluetun  | 💻 Email? quentin.mcgaw@gmail.com
gluetun  | 💰 Help me? https://www.paypal.me/qmcgaw https://github.com/sponsors/qdm12
gluetun  | 2025-11-20T20:38:03Z ERROR default route not found: in 4 route(s)
gluetun  | 2025-11-20T20:38:03Z INFO Shutdown successful

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:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
HTTPPROXY=on
HTTPPROXY_STEALTH=on

# See https://github.com/qdm12/gluetun-wiki/tree/main/setup#setup
VPN_SERVICE_PROVIDER=

# For OpenVPN define the following:
# VPN_TYPE=openvpn
# OPENVPN_USER=
# OPENVPN_PASSWORD=

# For Wireguard define the following:
VPN_TYPE=wireguard
WIREGUARD_PRIVATE_KEY=

# List of VPN countries to choose from
SERVER_COUNTRIES=France,Germany,Belgium,Netherlands,Denmark,Sweden,Norway

# Timezone for accurate log times
TZ=Europe/London

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.

1
2
3
4
5
6
function FindProxyForURL(url, host) {
    if (dnsDomainIs(host, "imgur.com")) {
        return "PROXY raspberrypi:8888";
    }
    return "DIRECT";
}

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.

You cannot include username and password as part of the PROXY statement.

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:

1
busybox httpd -f -p 8080 -h /var/www
The -f flag is used to keep the process in the foreground, necessary when containerizing the process.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
services:
  pacfile:
    image: busybox
    container_name: pacfile
    ports:
      - 8080:8080
    volumes:
      - ./my.pac:/var/www/my.pac
    command: busybox httpd -f -p 8080 -h /var/www 
  gluetun:
    ...

5. Point the PC’s proxy config to your PAC file
#

On Windows
  1. In the Settings app open Network & Internet > Proxy.
  2. Under Use setup script click Edit.
  3. Turn on Use setup script, enter the script address then select Save.
On Linux

Gnome users:
#

  1. Open System Tools > System Settings.
  2. Click Network then Network Proxy.
  3. Choose Automatic then enter the script address.

KDE users:
#

  1. Open System Settings > Network Settings
  2. Select Proxy
  3. 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).

David T. Jones
Author
David T. Jones
From robust infrastructure to elegant code, I solve complex tech challenges whilst channelling the same precision into 3-D art, cryptic crosswords and piano.