nscuro / traefik-plugin-geoblock

traefik plugin to whitelist requests based on geolocation
Apache License 2.0
39 stars 5 forks source link

Database file path incorrect #75

Open rama31244 opened 8 months ago

rama31244 commented 8 months ago

Hi, I attempted to install this plugin to my traefik docker container but it can't locate the database since the path is incorrect. I attempted to correct the path but the location of the database on my container seems to be dynamic and changes every restart:

/plugins-storage/sources/gop-**/src/github.com/nscuro/traefik-plugin-geoblock

The value after gop- seems to be a random 10 digit number that changes when restarting the container. How can I correct this? Can i copy out the database to another static folder on the docker container? Or does this database change periodically?

nscuro commented 8 months ago

Hey @rama31244, this seems to be a somewhat recent behavior change in how plugins are installed by traefik.

I personally install plugins in local mode (see https://plugins.traefik.io/install), which avoids this problem.

Can i copy out the database to another static folder on the docker container?

Yes, you can change the database file path to a location of your choice: https://github.com/nscuro/traefik-plugin-geoblock/blob/069f3ec4b950b3ee3cf938866ebbfc0b9bc19156/.traefik.yml#L10

Or does this database change periodically?

I try to keep the bundled database updated in with each plugin release. So yes, if you specify a custom database file path, you'd need to keep it updated on your own. This is easily to automate however, perhaps the dbdownload script I'm using can help as inspiration:

https://github.com/nscuro/traefik-plugin-geoblock/blob/main/tools/dbdownload/main.go

kopaygorodsky commented 5 months ago

Same happened for me today. Installed plugin as via helm chart traefik config

additionalArguments:
- --experimental.plugins.traefik-plugin-geoblock.modulename=github.com/nscuro/traefik-plugin-geoblock
- --experimental.plugins.traefik-plugin-geoblock.version=v0.14.0
apiVersion: traefik.io/v1alpha1
kind: Middleware
metadata:
    name: traefik-plugin-geoblock
spec:
    plugin:
        traefik-plugin-geoblock:
            enabled: true
            allowedCountries: [ "FR" ]
            # Blocklist of countries to block (ISO 3166-1 alpha-2)
            blockedCountries: [ "RU" ]
            defaultAllow: false
            disallowedStatusCode: 400
            databaseFilePath: /plugins-local/src/github.com/nscuro/traefik-plugin-geoblock/IP2LOCATION-LITE-DB1.IPV6.BIN

Same error, no "plugins-local" folder. Maybe it can read database as relative path ?