'ERR_TOO_MANY_REDIRECTS' error nginx docker

I am using nginx docker for deploying my app in aws server. I have to access my api using nginx proxy url which looks like https://domain.com/api/. This is a https request so i have to set proxy redirection to another port where api service running and the service is running under another docker container in same server instance. so my nginx conf file looks like below,

    server {
       listen         80;
       server_name    domain.com;
       return         301 https://$server_name$request_uri;
}

server {
       listen         443 ssl;
       server_name    domain.com;
       # add Strict-Transport-Security to prevent man in the middle attacks
       add_header Strict-Transport-Security "max-age=31536000";
       location /api/ {
            proxy_pass http://my-public-ip-address:3000;
        }

}

So my problem is that while I am trying to access the api endpoint using above url its showing ERR_TOO_MANY_REDIRECTS. So any one know about this issue? And also i went through all the article with same issue mentioned but no luck.

  • Packaging an app in docker that can be configured at run time
  • Read sym linked stdout in linux (with docker)
  • AWS Elastic Beanstalk VPC - HTTPS from ELB to instance
  • Database Fails to Start - Host Directory as a Data Volume
  • How do I create a docker machine with a specific URL using docker-machine and VirtualBox?
  • docker install nsenter , command not found
  • Docker-machine cannot connect to default machine (Windows)
  • Nginx docker (13: Permission denied) while logging request to mounted volume
  • Ubuntu 16.04 freeze when connecting to wireless network after starting docker daemon
  • Run multiple identical fig environment on the same host
  • Is Memory consumption is also Dynamic just like CPU for Docker Containers
  • deploy containers on swarm cluster using compose file without using docker machine
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.