Reputation: 705
How to setup two servers inside one AWS ec2 with nginx and Route 53?
Js server port = 5555, Spring app = 8888.
I have a domain name: xxxxxxxxxxxx.com
aws public ip yyyyyyyyyyyyyyy
aws public dns zzzzzzzzzzzzzzzzz
I need to set xxxxxxxxxxxx.com for js app
and api.xxxxxxxxxxxx.com for java app.
nginx
server {
# listen 80 default_server;
# listen [::]:80 default_server;
server_name zzzzzzzzzzzzzzzzz;
# root /usr/share/nginx/html;
location / {
proxy_pass http://localhost:8888;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
What should I place in route 53?
I have only new hosted zone for now.
Upvotes: 0
Views: 780
Reputation: 59966
You can point both DNS in route53 to your AWS instance public IP, and handle both bases on hostname in Nginx config.
server {
server_name xxxxxxxxxxxx.com
location / {
proxy_pass http://127.0.0.1:888;
}
}
server {
server_name api.xxxxxxxxxxxx.com;
location / {
proxy_pass http://127.0.0.1:5555;
}
}
Upvotes: 2