1

I have 2 instances one for backend(URL: be.domain.com) and another for frontend(URL: fe.domain.com) pointed through Backend-TG and frontend-TG respectively. AWS application load balancer used to configure the rules based on the host header.

ALB listener rules are 80 and 443 all HTTP requests are forced to https in alb and SSL used from ACM at the load balancer.

My Nginx conf for backend.conf:

server {
  server_name be.domain.com;
  listen 80;
  location /dashboard/ {
        include proxy_params;
        proxy_pass http://127.0.0.1:5050;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_redirect off;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
  }
  location /apipath/ {
        include proxy_params;
        proxy_pass http://127.0.0.1:5050;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_redirect off;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Nginx conf for frontend.conf:\

server {
   server_name fe.domain.com;
   listen 80;
    location /apipath/ {
           include proxy_params;
           proxy_pass         https://be.domain.com;
           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;

     }
     location /dashboard/ {
           include proxy_params;
           proxy_pass         https://be.domain.com;
           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;

     }
    location / {
         ## Your only path reference.
           root /var/www/code;
           index index.html index.htm;
           try_files $uri $uri/ /index.html;
   }
}

I have used the cname to create the domain aliasing with alb DNS.

the frontend is angular code and fe.domain.com proxy passing the API call to backend. Now I'm facing the issue of 502 status error in the API communication?

Any help would be appreciable. I feel some proxy passing issue. Can anyone guide me on this?

pbms
  • 111
  • 3

0 Answers0