阿里云OSS之Nginx反向代理配置

阿里云OSS对象存储的Nginx反向代理设置,修改nginx.conf文件

已华北2区域为例,在nginx.conf中添加:

########################## OSS #############################
  upstream ossproxy{
	server oss-cn-beijing-internal.aliyuncs.com;
	}
  server {
    listen 80;
    server_name ooo.xxx.com;
	error_page 404 http://ooo.xxx.com/error;
    location /nginx_status {
      stub_status on;
      access_log off;
      allow 127.0.0.1;
      deny all;
    }

    location ~ {
		proxy_pass http://ossproxy;
		proxy_redirect     off; 
        proxy_set_header   Host             ooxx.oss-cn-beijing-internal.aliyuncs.com;#Host要修改为OSS的域名或OSS控制台绑定的域名,否则OSS无法识别会报错 
        proxy_set_header   X-Real-IP        $remote_addr; 
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for; 
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; 
        proxy_max_temp_file_size 0; 
        proxy_connect_timeout      90; 
        proxy_send_timeout         90; 
        proxy_read_timeout         90; 
        proxy_buffer_size          4k; 
        proxy_buffers              4 32k; 
        proxy_busy_buffers_size    64k; 
        proxy_temp_file_write_size 64k; 
    }

  }

把相应的域名替换为自己的Endpoint域名和Bucket Name

你可能感兴趣的:(运维技术)