Search code examples
tensorflowauthenticationpasswordspassword-protectiontensorboard

Has anybody found a way to make Tensorboard password-protected?


I have been trying to make the Tensoboard password-protected, but it isn't easy as it is not a Flask app. An issue has been opened last year, but no news since.


Solution

  • As Tensorboard unfortunately does not have password-protection built-in, I used an nginx server within a docker container that acts as a reverse proxy.

    Tensorboard is then protected with HTTP basic auth.

    nginx.conf

    events { worker_connections 1024; }
    
    http {
      server {
        listen 5000;
    
        server_name localhost;
    
        location / {
          proxy_pass http://host.docker.internal:5000;
          auth_basic "Restricted Remote";
          auth_basic_user_file /etc/nginx/.htpasswd;
        }
      }
    }
    

    To generate the .htpasswd file use the following command:

    htpasswd -c .htpasswd admin
    

    docker-compose.yml

    version: '3'
    services:
      nginx:
        image: nginx:latest
        container_name: nginx_reverse_proxy
        volumes:
          - ./nginx.conf:/etc/nginx/nginx.conf
          - ./.htpasswd:/etc/nginx/.htpasswd
        ports:
          - 5000:5000
    

    To run use docker-compose up -d