Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bypass some file extensions #267

Closed
YrracOwl opened this issue Aug 22, 2023 · 3 comments
Closed

Bypass some file extensions #267

YrracOwl opened this issue Aug 22, 2023 · 3 comments
Assignees
Labels
discussion This topic needs some discussion.

Comments

@YrracOwl
Copy link

Is your feature request related to a problem? Please describe.
My font file and imags are stored under a samge directory named "data", but I just only want webp-server to handle images but bypass the font file ( .woff2 ).

Describe the solution you'd like
I ran this webp-server-go by docker, so I would like to use environment to config the bypass file extension.

Describe alternatives you've considered
config.json is also OK.

Additional context
I didn't find any information of proxying files, if this is a function that is already be implemented, can you give me the documention link or something else?

@n0vad3v
Copy link
Member

n0vad3v commented Aug 22, 2023

webp-server-go by docker

Are you using WebP Server Go to directly serve files?(e,g listening on port 80)

If you have a reverse proxy(like Nginx) in front of WebP Server Go, you can write configuration that only forward image requests to WebP Server Go, as below:

location ~* \.(?:jpg|jpeg|gif|png)$ {
    proxy_pass http://127.0.0.1:3333;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_hide_header X-Powered-By;
    proxy_set_header HOST $http_host;
    add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
}

Related docs page: https://docs.webp.sh/usage/usage-with-binary/

@YrracOwl
Copy link
Author

webp-server-go by docker

Are you using WebP Server Go to directly serve files?(e,g listening on port 80)

If you have a reverse proxy(like Nginx) in front of WebP Server Go, you can write configuration that only forward image requests to WebP Server Go, as below:

location ~* \.(?:jpg|jpeg|gif|png)$ {
    proxy_pass http://127.0.0.1:3333;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_hide_header X-Powered-By;
    proxy_set_header HOST $http_host;
    add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
}

Related docs page: https://docs.webp.sh/usage/usage-with-binary/

Actually I'm using cloudflare zero trust to bind webp-server with my domains, because I deployed webp-server-go on my NAS, and I can't get a public IP.

But your reply inspire me, thx a lot. I'll do some research.

@BennyThink
Copy link
Member

bypass you mean throw an error File extension not allowed! gif-animated.gif or return what it is?
If you want the second one, using nginx to pass only images is the best option for now.

@BennyThink BennyThink added the discussion This topic needs some discussion. label Oct 13, 2023
@n0vad3v n0vad3v closed this as completed Apr 10, 2024
@n0vad3v n0vad3v mentioned this issue Nov 27, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion This topic needs some discussion.
Projects
None yet
Development

No branches or pull requests

3 participants