Skip to content

Instantly share code, notes, and snippets.

@uhop
Last active May 25, 2024 17:02
Show Gist options
  • Save uhop/9177153 to your computer and use it in GitHub Desktop.
Save uhop/9177153 to your computer and use it in GitHub Desktop.

Revisions

  1. uhop revised this gist Feb 24, 2014. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions nginx-webp-sample.conf
    Original file line number Diff line number Diff line change
    @@ -43,6 +43,7 @@ http {

    location ~* ^/images/.+\.(png|jpg)$ {
    root /home/www-data;
    add_header Vary Accept;
    try_files $uri$webp_suffix $uri =404;
    }
    }
  2. uhop revised this gist Feb 23, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions nginx-webp-sample.conf
    Original file line number Diff line number Diff line change
    @@ -42,8 +42,8 @@ http {
    server_name localhost;

    location ~* ^/images/.+\.(png|jpg)$ {
    root /home/www-data;
    try_files $uri$webp_suffix $uri =404;
    root /home/www-data;
    try_files $uri$webp_suffix $uri =404;
    }
    }
    }
  3. uhop revised this gist Feb 23, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions nginx-webp-sample.conf
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,8 @@ http {
    tcp_nopush on;
    tcp_nodelay on;

    # IMPORTANT!!! Make sure that mime.types below lists WebP like that:
    # image/webp webp;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

  4. uhop created this gist Feb 23, 2014.
    47 changes: 47 additions & 0 deletions nginx-webp-sample.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    user www-data;

    http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    gzip on;
    gzip_disable "msie6";

    ##
    # Conditional variables
    ##

    map $http_accept $webp_suffix {
    default "";
    "~*webp" ".webp";
    }

    ##
    # Minimal server
    ##

    server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html;

    # Make site accessible from http://localhost/ or whatever you like
    server_name localhost;

    location ~* ^/images/.+\.(png|jpg)$ {
    root /home/www-data;
    try_files $uri$webp_suffix $uri =404;
    }
    }
    }