51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

nginx 代理到 阿里云oss

<Error>
<Code>NoSuchKey</Code>
Message>The specified key does not exist.</Message>RequestId>65BF4FA3BB04C593D3EAA356</RequestId>
HostId>kt-ai-assistant.oss-accelerate.aliyuncs.com</HostId<Key>oss/6a924781cda44b2d876d06038cfccdff 669x380.png</Key>EC>0026-00000001</EC>
<RecommendDoc>https://api.aliyun.com/troubleshoot?g=0026-00000001</RecommendDoc>Error>

这个是因为路径 图片上边加了一个 路径 /oss/

去掉的方式是 rewrite

rewrite ^/oss/(.*) /$1 break; #去掉路径/oss/

nginx:配置内网转发阿里云oss图片加水印-CSDN博客

通过ECS中Nginx反向代理到阿里云OSS内网,浏览器直接显示图片和文本_nignx缓存到oss-CSDN博客

具体配置如下:

       location ^~ /oss {
                rewrite ^/oss/(.*) /$1 break; #去掉路径/oss/
                # oss内网地址
		proxy_pass https://kt-ai-xxxxx.oss-accelerate.aliyuncs.com;
                # oss内网地址
                proxy_set_header Host kt-ai-xxxx.oss-accelerate.aliyuncs.com; 
		proxy_set_header X-Forwarded-Proto $scheme;
          	proxy_set_header X-Forwarded-Host $host;
          	proxy_set_header X-Forwarded-Server $host;
          	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          	proxy_set_header X-Real-IP $remote_addr;
	        proxy_http_version 1.1;
    	  	proxy_set_header Upgrade $http_upgrade;
    	  	proxy_set_header Connection "Upgrade";
	  	    proxy_read_timeout 1d;
          	proxy_send_timeout 1d;
                # 此处配置是为了把阿里云oss的返回的Content-Disposition隐藏掉,否则图片或文件在浏览器中会下载,不会显示。
		   # proxy_hide_header Content-Disposition;
       }
赞(8)
未经允许不得转载:工具盒子 » nginx 代理到 阿里云oss