"Use ELB to give EC2 two domains for WEB servers" In other words, "Register two domains for the WEB server with the ELB listener, and target the same EC2 (WEB server) as the target of the target group."
I did something that was almost eccentric, so I will leave a note of that time. It's just a feeling of temperature that you can do this kind of thing ... Yes, please understand. (Lol)
The configuration is as follows.
· Assign two domains to ELB listener rules and configure target groups to route 80 and 8080 ・ Start two nginx with Docker
"ELB"-> "EC2"-> "Docker"-> "nginx": Waiting on port 80 (assumed to be nginx1)
→ "nginx": Waiting on port 8080 (let's say nginx2)
Therefore,
・ "Https" for "nginx1"://hoge.So that you can access it with "com" ...
・ "Https" for "nginx2"://fuga.So that you can access it with "com" ...
To do.
You need to prepare two domains, so please cut the subdomain.
Well, it's an eccentricity anyway.
Please refer to the following for VPC, EC2, ELB construction, domain setting, etc. The flow up to construction is developed with easy-to-understand explanations.
・ Introduction to AWS starting from 0: Overview → https://qiita.com/hiroshik1985/items/6433d5de97ac55fedfde ・ Introduction to AWS starting from 0 ①: VPC → https://qiita.com/hiroshik1985/items/9de2dd02c9c2f6911f3b ・ Introduction to AWS starting from 0 ②: EC2 → https://qiita.com/hiroshik1985/items/f078a6a017d092a541cf ・ Introduction to AWS starting from 0 ③: ELB → https://qiita.com/hiroshik1985/items/ffda3f2bdb71599783a3
As a target group for the first "nginx1"
-On the target group construction screen, select "Instances"-> "Enter target group name"-> "Port 80"-> "Created VPC"-> What's good-> "Next"
-Select the EC2 built in Available instances and select "Include as pending below" → "Create target group"
As a target group for the second "ngin x2"
-On the target group construction screen, select "Instances"-> "Enter target group name"-> "Port 8080"-> "Created VPC"-> What's good-> "Next"
-Select the EC2 built in Available instances and select "Include as pending below" → "Create target group"
As a listener rule for the first "nginx1"
-On the load balancer construction screen, select the target load balancer and select the "Listener" tab.
・ "Display rule" in the rule part/Select "Edit"
-Insert the rule and set the condition to "Host header"...Select and enter "WEB Server Domain" as the value.
-Select Add Action and assign the target group created for "nginx1"
As a listener rule for the second "ngin x2"
-On the load balancer construction screen, select the target load balancer and select the "Listener" tab.
・ "Display rule" in the rule part/Select "Edit"
-Insert the rule and set the condition to "Host header"...Select and enter "WEB Server Domain" as the value.
· Select Add Action and assign the target group created for "nginx2"
I think it's really eccentric and I don't think I'll do it,
・ It is troublesome to build a server
・ It just seems to work, so let's create it as a development environment for the time being
·moved
・ There is no problem with the program, so throw it away
I think it's good when you want to do something.
Recommended Posts