![如果来自社交媒体网站,如何使用 Nginx 不进行重定向?](https://linux22.com/image/774273/%E5%A6%82%E6%9E%9C%E6%9D%A5%E8%87%AA%E7%A4%BE%E4%BA%A4%E5%AA%92%E4%BD%93%E7%BD%91%E7%AB%99%EF%BC%8C%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20Nginx%20%E4%B8%8D%E8%BF%9B%E8%A1%8C%E9%87%8D%E5%AE%9A%E5%90%91%EF%BC%9F.png)
如果来自社交媒体网站(如 reddit、facebook 和 twitter),我该如何不强制重定向?目前我的设置是重定向对图像文件的任何直接访问,但如果来自社交媒体网站,我不想重定向,以便它可以获取图像预览。
proxy_cache_path /var/www/img.example.com/htdocs/cache-store levels=1:2 keys_zone=pixstore:10m max_size=5g inactive=7d use_temp_path=off;
server {
server_name img.example.com www.img.example.com;
access_log /var/log/nginx/img.example.com.access.log ;
error_log /var/log/nginx/img.example.com.error.log;
add_header X-Proxy-Cache $upstream_cache_status;
location / {
proxy_cache pixstore;
proxy_cache_revalidate on;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_lock on;
add_header X-Cache-Status $upstream_cache_status;
proxy_pass http://xxx.xxx.xxx.xxx:8090;
proxy_redirect off;
include proxy_params;
proxy_cache_valid 200 7d;
proxy_cache_valid 404 5m;
}
location ~ "^/c/600x1200_90_webp/img-master/img/\d+/\d+/\d+/\d+/\d+/\d+/((?<filenum>\d+)[^/]+\.(jpg|png|webp))$" {
proxy_pass http://xxx.xxx.xxx.xxx:8090;
return 301 http://view.example.com/artwork/$filenum;
}
}