0
server {
  ...
  location /static/ {
    proxy_set_header <bucket_name>.s3.ap-northeast-2.amazonaws.com;
    proxy_pass https://<bucket_name>.s3.ap-northeast-2.amazonaws.com/static/;
  }
}

this works well. but below code get 403(access denied error from aws)

server {
  set $bucket "<bucket_name>.s3.ap-northeast-2.amazonaws.com";

    location /static/ {
      proxy_set_header Host $bucket;
      proxy_pass https://$bucket/static/;
    }
}

Did I make mistake? I don't unserstand why $bucket variable not working well..

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Sam Kim
  • 113
  • 1
  • 9
  • Does this answer your question? [NGINX - Using variable in proxy\_pass breaks routing](https://stackoverflow.com/questions/46230270/nginx-using-variable-in-proxy-pass-breaks-routing) – slauth Nov 02 '21 at 07:05
  • You are right. But I want to use proxy_pass like proxy_pass https://$bucket/static-green/ in location static; How can I modify request_uri?? This is another question. – Sam Kim Nov 03 '21 at 01:36
  • Sorry I don't quite get it. But anyway, you'd better open a new question in this case. – slauth Nov 03 '21 at 07:43

0 Answers0