Reputation: 4207
I would like to know, how can we completely migrate from NGiNX
to AWS ELB
including SSL
(AWS certificate) ?
I have following NGiNX
configuration for one of my domain(for example, example.com
)
server {
listen 80;
server_name *.example.com;
root /home/ubuntu/angularApp;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
}
server {
listen 80;
server_name example.com;
root /home/ubuntu/website;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
location ~ ^/api/(v1|v2)/ {
proxy_pass http://backend_service$request_uri;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Google-Real-IP $remote_addr;
}
}
I have mainly 2-query,
Query#1 :-
How to configure a setting(in ELB
) for Angular-App pages
if requested URL contains/belongs subdomain
otherwise refer other directory's index.html file instead of Angular-App.
Query#2 :-
How to configure a setting(in ELB
) to point API which is running on someother port on the same server(EC2
) if incoming request's URI
contain /api/v1/
or /api/v2/
NOTE - I have already approved AWS SSL Certificate which we can configure in ELB. so regarding SSL Certificate there won't be any issue. Currently I am using other than AWS's SSL certificate which is configured into NGiNX but have planned to use AWS ACM since all other things belongs to within AWS.
Any help would be really appreciable !!
Upvotes: 2
Views: 2326
Reputation: 484
You need to do the following:
/api/v1/
or /api/v2/
can go to different backends. Here when you configure you could choose IP of the target backend IF you prefer that instead of choosing instances (Which is the default).I hope this answers your questions to certain extent. The oficial docs are here for more information or feel free to ask further.
Upvotes: 2