增加图片压缩

This commit is contained in:
LingZhaoHui 2020-08-23 13:34:22 +08:00
parent 7a1c3d980f
commit 14e60305bc
1 changed files with 39 additions and 11 deletions

View File

@ -20,6 +20,7 @@ server {
}
location / {
add_header Strict-Transport-Security "max-age=31536000";
fastcgi_pass_header Set-Cookie;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
@ -32,18 +33,44 @@ server {
try_files $uri $uri/ /api.php;
}
location ~ "^(/images/.*\.(jpg|png|jpeg))!(\d+)-(\d+)$" {
set $w $3;
set $h $4;
rewrite ^(/images/.*\.(jpg|png|jpeg))!(\d+)-(\d+)$ $1 break;
image_filter resize $w $h;
try_files $1 404;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Access-Control-Allow-Origin "*";
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_cache cache_one;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 302 10d;
proxy_cache_valid 301 304 10d;
proxy_cache_valid any 10d;
expires 10d;
proxy_redirect off;
add_header wall "Stay simple, stay naive.";
}
location ~ .(jpg|png|gif|css|js|pdf|scss|ico|jpeg|bmp|flv|mp4|mp3|swf|wma|wmv|asf|mmf|zip|rar|gz|woff2|woff|ttf)$ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_cache cache_one;
proxy_cache_valid 200 302 30d;
proxy_cache_valid 301 30d;
proxy_cache_valid any 30d;
expires 30d;
proxy_redirect off;
add_header wall "Stay simple, stay naive.";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Access-Control-Allow-Origin "*";
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_cache cache_one;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 302 10d;
proxy_cache_valid 301 304 10d;
proxy_cache_valid any 10d;
expires 10d;
proxy_redirect off;
add_header wall "Stay simple, stay naive.";
}
location /ads.txt {
autoindex on;
@ -61,6 +88,7 @@ server {
include snippets/fastcgi-php.conf;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#fastcgi_index index.php;
fastcgi_pass_header Set-Cookie;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
include fastcgi_params;
}