From 14e60305bc721cbfc42eb23546a6e6555d7e07f8 Mon Sep 17 00:00:00 2001 From: zeekling Date: Sun, 23 Aug 2020 13:34:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87=E5=8E=8B?= =?UTF-8?q?=E7=BC=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx/sites-enabled/img.conf | 50 ++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/nginx/sites-enabled/img.conf b/nginx/sites-enabled/img.conf index 7d22ea3..29b7cf2 100644 --- a/nginx/sites-enabled/img.conf +++ b/nginx/sites-enabled/img.conf @@ -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; }