If using the default stacks, add the following two lines in docksal.env or docksal-local.env.
Apache
APACHE_BASIC_AUTH_USER=user
APACHE_BASIC_AUTH_PASS=password
Nginx
NGINX_BASIC_AUTH_USER=user
NGINX_BASIC_AUTH_PASS=password
If using custom configuration, modify your .docksal/docksal.yml or .docksal/docksal-local.yml.
Add the following two lines to the web service and run fin project start to apply changes:
Apache
  web:
    ...
    environment:
      ..
      - APACHE_BASIC_AUTH_USER=user
      - APACHE_BASIC_AUTH_PASS=password
      ...
Nginx
  web:
    ...
    environment:
      ..
      - NGINX_BASIC_AUTH_USER=user
      - NGINX_BASIC_AUTH_PASS=password
      ...