阿里云OSS使用nginx反代提供服务

in 后端 with 0 comment

有时候使用了阿里云OSS,但是想用ECS反代来提供服务
配置如下;

OSS需要配置权限允许ecs的ip访问;注意:如果使用bucket权限需要配置ecs的内网ip。

server {
    listen 80;
    listen [::]:80;
    server_name   xx.xx.com;
    root /var/www/xx;

    index index.html index.htm;

    charset utf-8;

    location / {
      try_files $uri $uri/ /index.html;
    }
    location /images/  {
      proxy_pass http://fc-console-gen-cn-shanghai-123.oss-cn-shanghai-internal.aliyuncs.com/;
      
      proxy_hide_header Content-Disposition;
      proxy_hide_header x-oss-request-id;
      proxy_hide_header x-oss-object-type;
      proxy_hide_header x-oss-hash-crc64ecma;
      proxy_hide_header x-oss-storage-class;
      proxy_hide_header x-oss-force-download;
      proxy_hide_header x-oss-server-time;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    access_log   /var/log/nginx/xx.xx.com.log;
}
Comments are closed.