NGINX configuration to forward request on to ALB

1.7k Views Asked by At

Have to create 3 tier architecture on AWS. my simple environment works like this: User ----> Eternal application load balancer ---> NGINX web server ----> internal application load balancer ----> Apache application server. When i hit to external load balancer dns it should connect to apache web server. So what configuration should i make on NGINX and in which files so it forwards my requests from external load balancer to internal load balancer so i can able to connect to my apache server.

Please help me on this.

1

There are 1 best solutions below

0
MassHysteria On BEST ANSWER

If the External LB points to NGINX, then the proxy_pass directive value on NGINX should be the internal LB, which, if I understood correctly, routes to the Apache server.

You can configure a server block and inside it a location block in nginx.conf under /etc/nginx OR create a separate virtual host config file for the site that points to the External ELB under the sites-enabled folder.

For example:

server {

listen 80;
listen 443 ssl;

server_name some.domain.com; #the site that points to the External ELB
ssl_certificate /etc/ssl/certs/cert.crt;
ssl_certificate_key /etc/ssl/certs/domain.key;

location / {
 proxy_pass http://internal-kubinator-dev-54521756.us-ea1.elb.amazozonaws.com/; #Pass the request to the internal ELB