Điểm:0

How to set up conditional redirects on an Application Load Balancer for an Elastic Beanstalk environment?

lá cờ ng

I have two Docker-based single-instance Elastic Beanstalk environments (one for staging and one for production).

I'd like to migrate the (Elastic Beanstalk) application to sit behind a load balancer (primarily to take advantage of AWS Certificate Manager).

Currently I'm using .ebextensions to customise the Nginx config to satisfy my application's traffic routing requirements:

  • For path /xyz/, traffic should go to the app via port 80 (i.e. HTTP)
  • For all other requests to port 80, a (301) redirect response to port 443 (HTTPS) should be emitted.
  • All requests on port 443 (HTTPS) should pass through to the app.

So my question is: how do I achieve those routing requirements using a load balancer in front of one of my Elastic Beanstalk environments? I'm thinking to have one load balancer per environment, for the sake of flexibility.

I've come across the following possible solutions (none of which seem ideal):

  1. Set up a new Elastic Beanstalk environment with a dedicated Application Load Balancer and then modify the load balancer's listeners and rules via the EC2 console service (similar to what this Elastic Beanstalk documentation entry seems to be suggesting, under "Redirect HTTP traffic to HTTPS > Configure load balancer").
  2. Set up a new Application Load Balancer via the EC2 console service, create a new Elastic Beanstalk environment connected to the new Application Load Balancer as a Shared Application Load Balancer and then follow these guides (this and this) to (hopefully?) ensure that the load balancer and Elastic Beanstalk environment are in sync (in terms of instance management and traffic routing).
  3. Set up a new Elastic Beanstalk environment with a dedicated Application Load Balancer and then modify the application so that it listens on three ports (one for the /xyz/ traffic, one for the HTTP -> HTTPS redirection and one for the HTTPS traffic), which the docs here appear to be telling me to do (but make no mention of how to achieve multiple listening ports on a single app).

Options one and two involve going behind Elastic Beanstalk's "back" to modify underlying resources (which I'm hesitant to do) and the third option would require me to modify my application (which I'd like to try and avoid).

Are any of these options advised? Is there a better option?

Điểm:0
lá cờ ng

Sau khi liên hệ với bộ phận hỗ trợ kỹ thuật của AWS về vấn đề này, tôi có thể xác nhận rằng:

  • Tùy chọn thứ hai được hỗ trợ và các hướng dẫn tôi đã đề cập là không cần thiết. I E. Miễn là bạn chọn bộ cân bằng tải ứng dụng (được tạo từ EC2) làm bộ cân bằng tải dùng chung (trong môi trường Elastic Beanstalk của bạn), chúng sẽ được đồng bộ hóa (về định tuyến lưu lượng thích hợp đến các phiên bản trong môi trường).
  • Một khả năng khác là chọn tùy chọn đầu tiên, nhưng thay vì sửa đổi bộ cân bằng tải trong EC2 (điều mà tôi đoán là không được khuyến nghị), bạn có thể sử dụng ".ebextensions" để sửa đổi bộ cân bằng tải. Vì vậy, nói chung, bất cứ khi nào bảng điều khiển AWS không cung cấp GUI để đạt được các yêu cầu của Elastic Beanstalk, thì ".ebextensions" có thể được sử dụng để xử lý GUI của bảng điều khiển Elastic Beanstalk bị thiếu.
Rami avatar
lá cờ us
Bạn có bất kỳ mẫu nào về cách bạn đã thực hiện sửa đổi trong CloudFormation không, tôi hiện đang gặp vấn đề gần như tương tự.
lá cờ ng
Không, xin lỗi, tôi chưa sử dụng CloudFormation.

Đăng câu trả lời

Hầu hết mọi người không hiểu rằng việc đặt nhiều câu hỏi sẽ mở ra cơ hội học hỏi và cải thiện mối quan hệ giữa các cá nhân. Ví dụ, trong các nghiên cứu của Alison, mặc dù mọi người có thể nhớ chính xác có bao nhiêu câu hỏi đã được đặt ra trong các cuộc trò chuyện của họ, nhưng họ không trực giác nhận ra mối liên hệ giữa câu hỏi và sự yêu thích. Qua bốn nghiên cứu, trong đó những người tham gia tự tham gia vào các cuộc trò chuyện hoặc đọc bản ghi lại các cuộc trò chuyện của người khác, mọi người có xu hướng không nhận ra rằng việc đặt câu hỏi sẽ ảnh hưởng—hoặc đã ảnh hưởng—mức độ thân thiện giữa những người đối thoại.