Created
December 13, 2017 07:23
-
-
Save hirokazumiyaji/77b2d3d7468972acfeee3d742e73e745 to your computer and use it in GitHub Desktop.
nginx webp conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name localhost; | |
location ~ ^/assets/images/.+\.(?:gif|jpg|png)$ { | |
if ($http_accept ~* "webp") { | |
add_header Vary Accept; | |
rewrite (.+)\.(?:gif|jpg|png) $1.webp last; | |
} | |
if ($http_user_agent ~* "(Chrome|Opera|Android|Android.*Chrome)") { | |
add_header Vary User-Agent; | |
rewrite (.+)\.(?:gif|jpg|png) $1.webp last; | |
} | |
root /var/www/; | |
try_files $uri @s3 =404; | |
} | |
location ~ ^/assets/images/.+\.webp$ { | |
root /var/www/; | |
try_files $uri @s3 =404; | |
} | |
location @s3 { | |
proxy_pass https://bucket.s3.aws.com; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment