text.txt 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * @Author: sjl
  3. * @Date: 2023-07-10 17:52:00
  4. * @Descripttion:
  5. */
  6. location /images/ {
  7. proxy_pass http://remote-server/images/;
  8. proxy_set_header Host $host;
  9. proxy_cache off;
  10. proxy_store on;
  11. proxy_store_valid 200 1d;
  12. proxy_store_access user:rw group:rw all:r;
  13. proxy_temp_path /path/to/store/temp/files;
  14. rewrite /images/(.*) /$1 break;
  15. sub_filter_types *;
  16. sub_filter_once off;
  17. sub_filter http://remote-server/images/ /path/to/save/files/;
  18. root /path/to/save/files/;
  19. try_files $uri $uri/ =404;
  20. }
  21. # 配置不缓存的文件类型
  22. location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
  23. expires 1M;
  24. add_header Cache-Control "public";
  25. # 启用gzip压缩
  26. gzip on;
  27. gzip_comp_level 5;
  28. gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
  29. gzip_vary on;
  30. gzip_disable "MSIE [1-6]\.(?!.*SV1)";
  31. # 如果您还想使用不同的缓存时间限制,请添加下面的行并设置正确的时间
  32. # expires 1h;
  33. }
  34. location /map/ {
  35. # 远程服务器的URL
  36. proxy_pass https://remote-server.com/;
  37. # 设置响应状态码
  38. proxy_intercept_errors on;
  39. error_page 404 =200 /map/$1;
  40. # 将响应内容保存到本地文件系统中
  41. proxy_store on;
  42. proxy_store_access user:rw group:rw all:r;
  43. proxy_temp_path /path/to/nginx/temp;
  44. }
  45. location /map/ {
  46. proxy_pass https://remote-server.com/;
  47. proxy_store on;
  48. proxy_store_access user:rw group:rw all:r;
  49. proxy_temp_path /path/to/nginx/temp;
  50. proxy_set_header Host $http_host;
  51. proxy_set_header X-Real-IP $remote_addr;
  52. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  53. # 处理返回的响应头和内容
  54. proxy_hide_header X-Accel-Expires;
  55. proxy_hide_header Cache-Control;
  56. add_header Cache-Control "public";
  57. add_header X-Proxy-Cache $upstream_cache_status;
  58. # 重定向文件请求到本地存储的路径
  59. rewrite ^/map/(.*)$ /map/$1 break;
  60. }