Architecture of distributing requests to AWS and Xserver

Asked 1 years ago, Updated 1 years ago, 96 views

■Question
Depending on the path under hoge.com at the time of the request, we would like to sort the request to the AWS ALB or XServer.What should I do?

■ Situation
- Own a domain called hoge.com
- I want to sort requests to AWS ALB or XServer according to the path under hoge.com.
- Now I have DNS configuration for hoge.com to go to Xserver

■ AWS ALB
TG TG-EC2 (Service A with Rails)
TG TG-EC2 (Service B with Rails)
https://hoge.com/servicea/*
https://hoge.com/serviceb/*

■ Xserver
Xserver (Service C with WP)
http://hoge.com
http://hoge.com/about
http://hoge.com/blog

■What's troubling you
- Unable to set reverse proxy on Xserver and cannot request AWS side
- Even though AWS ALB is the primary contract for the request, ALB cannot forward the request to Xserver

■ Supplemental
If it's a different service, I think it's better to use a subdomain in the first place.
I would appreciate it if you could give me advice including that.

aws nginx

2022-09-30 21:27

1 Answers

As you know, the ALB target is EC2, so you cannot transfer the request directly to Xserver.
It is possible if you prepare EC2 to proxy to Xserver by nginx, but I think it is not beneficial to use Xserver.

A possible configuration for AWS is CloudFront.

  • Created a CloudFront web distribution.hoge.com on CNAME
  • Create two origin
    • pointing to ALB
    • Pointing to Xserver
  • Behavior, depending on the path, toward ALB and Xserver
  • pointing to ALB
  • Pointing to Xserver

Note that, by default, CloudFront side cache is enabled, so you must disable the cache or configure it to transfer the required headers depending on the nature of the content.

If it's a different service, I think it's better to use a subdomain.

If you switch off the subdomain, you can only configure DNS, so you don't have to worry about it, but if you are already running a service, you may need to configure redirect settings from the perspective of SEO.
If it's new, I think it's easier to separate it.


2022-09-30 21:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.