webp_server_go icon indicating copy to clipboard operation
webp_server_go copied to clipboard

Exclude certain sub folder

Open pixiemediaweb opened this issue 1 year ago • 1 comments

Is it possible to exclude certain folders?

My config has;

{ "HOST": "127.0.0.1", "PORT": "3333", "QUALITY": "80", "IMG_PATH": "/var/www/live/pub", "EXHAUST_PATH": "/var/www/webpcache", "IMG_MAP": {}, "ALLOWED_TYPES": ["jpg","png","jpeg","bmp","svg","heic","nef"], "ENABLE_AVIF": false, "ENABLE_EXTRA_PARAMS": false "READ_BUFFER_SIZE": 4096, "CONCURRENCY": 262144, "DISABLE_KEEPALIVE": false }

But id like it to exclude images that live in /var/www/live/pub/some-folder

Is this possible?

pixiemediaweb avatar Nov 29 '23 00:11 pixiemediaweb

Currently there is no way to do this on WebP Server Go, however there are some workarounds:

  • If you're using a reverse proxy like Nginx in front of it, you can add some path to make requests denied on Nginx, like:
server {
    listen 80;
    server_name your_domain.com;

    location / {
        proxy_pass http://localhost:3333;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location ^~ /pub/some-folder {
        deny all;
        return 403;
    }
}
  • If there aren't too much directories under /var/www/live/pub, maybe you can use IMG_MAP config to specify paths, more info can be seen at https://docs.webp.sh/usage/multipath/

n0vad3v avatar Nov 29 '23 08:11 n0vad3v