Search code examples
amazon-s3amazon-cloudfrontamazon-ecs

Creating proxy_pass from s3 static web server bucket to instance docket


  • I'm trying to load our current application to CloudFront-s3 static web site architecture.
  • after creating s3 bucket and CloudFront which work, I'm trying to configure our backend to go to a specific instance and port.

Currently, I'm doing it with nginx:

 location /api {
        proxy_pass http://my_app:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }
  client_max_body_size 1000M;
  server_tokens off;

is there a way to configure it on the s3bucket I created?


Solution

  • No, you cannot proxy a path to another server within S3, that only supports static objects served by S3 directly.

    But you can handle this in Cloudfront by adding an extra behaviour which points to your other instance/port see https://aws.amazon.com/premiumsupport/knowledge-center/cloudfront-distribution-serve-content/