how to protect a django web app deployed in elastic beanstalk docker nginx using password

I’ve a django web application hosted in AWS Elastic Beanstalk with Docker and Nginx. I am using supervisor to start nginx and uwsgi. Need to protect it the website using password. I’ve tried using .htaccess.

htpasswd -cb /etc/nginx/.htpasswd admin admin 

and added the nginx config with

  • Deploying project in Docker with Angular 4, Django and postgresql
  • Trying to find reason for 500 error when running a Django site in Nginx
  • Docker: exposed ports cannot be accessed in another container
  • permission issue for collectstatic in docker-compose
  • Cannot connect to MySQL docker container from container with Django app
  • Multiple docker compose environments for same code base
  •  location / {
       auth_basic "Restricted";
       auth_basic_user_file  /etc/nginx/.htpasswd;
       uwsgi_pass unix:/var/sockets/api.sock;
       include    /home/docker/uwsgi_params; 

    It’s working but its asking password repeatedly. Usually htaccess only asks password once in session. But it asks for username and password every time we click one field or button. Is there any way to fix it?

  • docker container fails to start after docker deamon has been restarted
  • boot2docker is autoupgrading
  • wrapping DB in docker image
  • Receiving http response inside a Docker container
  • mysql_upgrade failed - innodb tables doesn't exist?
  • Get all containers/images using docker-java client library [closed]
  • Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.