Sign in

Mod for swag

DB-IP country database

Downloads the free DB-IP country lite GeoIP2 database to /config/geoip2db and refreshes it weekly, with an nginx geoip2 config for allowing or blocking countries and continents.

arch
amd64, arm64
built

Use it#

Set DOCKER_MODS on the swag container and recreate it. The mod is pulled on every start; several mods are separated with |.

DOCKER_MODS=ghcr.io/linuxserver-playground/mods:swag-dbip

:swag-dbip always gets the newest build. To stay on this one, pin its tag:

DOCKER_MODS=ghcr.io/linuxserver-playground/mods:swag-dbip-5e18c29
services:
  swag:
    image: ghcr.io/linuxserver-playground/swag:latest
    environment:
      - DOCKER_MODS=ghcr.io/linuxserver-playground/mods:swag-dbip

Details#

This mod downloads the dbip-country-lite.mmdb database under /config/geoip2db and updates it weekly through the container’s periodic cron. On first run it copies a default /config/nginx/dbip.conf.

This mod should not be enabled together with the swag-maxmind or swag-ipinfo mods.

Follow these steps to enable the dbip mod:

  1. Set DOCKER_MODS=ghcr.io/linuxserver-playground/mods:swag-dbip on the container and recreate it.

  2. Add the following line to /config/nginx/nginx.conf under the http section:

    include /config/nginx/dbip.conf;
  3. Edit /config/nginx/dbip.conf and add countries to the blocklist / whitelist according to the comments, for example:

    map $geoip2_data_country_iso_code $geo-whitelist {
        default no;
        UK yes;
    }
    
    map $geoip2_data_country_iso_code $geo-blacklist {
        default yes;
        US no;
    }
  4. Use the definitions in your server blocks:

    server {
        listen 443 ssl;
        listen [::]:443 ssl;
    
        server_name some-app.*;
        include /config/nginx/ssl.conf;
        client_max_body_size 0;
    
        if ($lan-ip = yes) { set $geo-whitelist yes; }
        if ($geo-whitelist = no) { return 404; }
    
        location / {

    Or, for a blacklist with both some countries and continents:

        if ($lan-ip = yes) { set $geo-blacklist yes; }
        if ($geo-blacklist = no) { return 404; }
        if ($continent-blacklist = no) { return 404; }
  5. Restart the container to apply the changes.

Community project

Improve this mod, or make your own

Mods are how LinuxServer images grow without getting heavier: a Dockerfile, a few scripts and a mod.yml. If this one is missing something, or you need one like it for another image, an AI agent in our harness can build and test it with you.

Ask your agent

  • The swag-dbip mod <what is wrong>. Fix it, test it and draft the PR.
  • Make a mod like swag-dbip for <another image>, and test it.

Making a mod Every way to help Get the harness (opens in a new tab)

Source: swag-dbip branch (opens in a new tab). Every mod