Sign in

Mod for swag

Maxmind

This mod adds the maxmind database to nginx using the license key defined in the environment variable.

arch
amd64
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-maxmind

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

DOCKER_MODS=ghcr.io/linuxserver-playground/mods:swag-maxmind-f84eceb
services:
  swag:
    image: ghcr.io/linuxserver-playground/swag:latest
    environment:
      - DOCKER_MODS=ghcr.io/linuxserver-playground/mods:swag-maxmind

Details#

This mod downloads the GeoLite2-City.mmdb database under /config/geoip2db, the database is updated weekly.

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

Follow these steps to enable the maxmind mod:

  1. Acquire a maxmind license here: https://www.maxmind.com/en/geolite2/signup

  2. In the container’s docker arguments, set an environment variable DOCKER_MODS=ghcr.io/linuxserver-playground/mods:swag-maxmind

  3. In the container’s docker arguments, set the following environment variables:

    • MAXMINDDB_LICENSE_KEY=<license-key> with your license key.
    • MAXMINDDB_USER_ID=<account-id> with your account id.
  4. Recreate the container to apply the changes.

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

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

    map $geoip2_data_country_iso_code $geo-whitelist {
        default no;
        GB yes;
    }
    
    map $geoip2_data_country_iso_code $geo-blacklist {
        default yes;
        US no;
    }
  7. Use the definitions in the following way:

     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 / {
  8. 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-maxmind mod <what is wrong>. Fix it, test it and draft the PR.
  • Make a mod like swag-maxmind for <another image>, and test it.

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

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