ADJ網路實驗室
打印

[介紹] 使用 Nginx reverse proxy 反向代理 AWS S3 resources

使用 Nginx reverse proxy 反向代理 AWS S3 resources

需求:
1.實現代理s3的nginx緩存服務器
2.實現nginx代理服務器的 / 路徑到s3的指定目錄映射,即 / -> bucket-name.s3-website-ap-northeast-1.amazonaws.com/

最重要的就是在 server { } 中加上底下這段:
引用:

        location / {
            proxy_http_version     1.1;
            proxy_set_header       Connection "";
            proxy_set_header       Authorization '';
            proxy_set_header       Host bucket-name.s3-website-ap-northeast-1.amazonaws.com;
            proxy_hide_header      x-amz-id-2;
            proxy_hide_header      x-amz-request-id;
            proxy_hide_header      x-amz-meta-server-side-encryption;
            proxy_hide_header      x-amz-server-side-encryption;
            proxy_hide_header      Set-Cookie;
            proxy_ignore_headers   Set-Cookie;
            proxy_intercept_errors on;
            add_header             Cache-Control max-age=31536000;
            proxy_pass             http://bucket-name.s3-website-ap-northeast-1.amazonaws.com/;
        }


這樣就可以囉~

參考資料:
https://stackoverflow.com/questions/44639182/nginx-proxy-amazon-s3-resources/44749584#44749584





TOP

ARTERY.cn