| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /*
- * @Author: sjl
- * @Date: 2023-07-10 17:52:00
- * @Descripttion:
- */
- location /images/ {
- proxy_pass http://remote-server/images/;
- proxy_set_header Host $host;
-
- proxy_cache off;
- proxy_store on;
- proxy_store_valid 200 1d;
- proxy_store_access user:rw group:rw all:r;
- proxy_temp_path /path/to/store/temp/files;
- rewrite /images/(.*) /$1 break;
- sub_filter_types *;
- sub_filter_once off;
- sub_filter http://remote-server/images/ /path/to/save/files/;
-
- root /path/to/save/files/;
- try_files $uri $uri/ =404;
- }
- # 配置不缓存的文件类型
- location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
- expires 1M;
- add_header Cache-Control "public";
-
- # 启用gzip压缩
- gzip on;
- gzip_comp_level 5;
- gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
- gzip_vary on;
- gzip_disable "MSIE [1-6]\.(?!.*SV1)";
-
- # 如果您还想使用不同的缓存时间限制,请添加下面的行并设置正确的时间
- # expires 1h;
- }
- location /map/ {
- # 远程服务器的URL
- proxy_pass https://remote-server.com/;
-
- # 设置响应状态码
- proxy_intercept_errors on;
- error_page 404 =200 /map/$1;
-
- # 将响应内容保存到本地文件系统中
- proxy_store on;
- proxy_store_access user:rw group:rw all:r;
- proxy_temp_path /path/to/nginx/temp;
- }
- location /map/ {
- proxy_pass https://remote-server.com/;
- proxy_store on;
- proxy_store_access user:rw group:rw all:r;
- proxy_temp_path /path/to/nginx/temp;
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- # 处理返回的响应头和内容
- proxy_hide_header X-Accel-Expires;
- proxy_hide_header Cache-Control;
- add_header Cache-Control "public";
- add_header X-Proxy-Cache $upstream_cache_status;
- # 重定向文件请求到本地存储的路径
- rewrite ^/map/(.*)$ /map/$1 break;
- }
|