Sign in

Mod for swag

IPINFO

This mod downloads the ipinfolite.mmdb database under /config/geoip2db, the database is updated daily.

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-ipinfo

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

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

Details#

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

Follow these steps to enable the ipinfo mod:

  1. Sign up and aquire an ipinfo token here: https://ipinfo.io/signup

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

    • IPINFO_TOKEN=<token> with your token.
  3. In the container’s docker arguments, set an environment variable DOCKER_MODS=ghcr.io/linuxserver-playground/mods:swag-ipinfo

  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/ipinfo.conf;
  6. Edit /config/nginx/ipinfo.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;
    }
  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 / {

    Or for blacklist with both some countries and continents:

    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-blacklist yes; }
        if ($geo-blacklist = no) { return 404; }
        if ($continent-blacklist = 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-ipinfo mod <what is wrong>. Fix it, test it and draft the PR.
  • Make a mod like swag-ipinfo for <another image>, and test it.

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

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