'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.

  • Why not found, while it does exist?
  • Docker orchestration
  • cannot ADD file in current directory or in the directory with full path
  • What is the difference between running docker image in and outside of vagrant?
  • Why are my AWS CodeBuild commands not running?
  • Configure uwsgi and nginx using Docker
  • How is Docker different from a normal virtual machine?
  • Docker: Mixing distros - any disadvantage?
  • docker.io - Connecting to MySQL with Scala
  • Better rules for gnu make with docker
  • Docker Daemon startup error using clustering in AWS
  • jenkins pipeline docker build on docker agent
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.