我一直在尝试对Tensoboard设置密码保护,但这并不容易,因为它不是Flask应用程序。 issue去年已打开,但此后没有消息。

最佳答案

不幸的是,由于Tensorboard没有内置密码保护功能,因此我在docker容器中使用了nginx服务器作为反向代理。

然后使用HTTP基本身份验证保护Tensorboard。

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;
    }
  }
}


要生成.htpasswd文件,请使用以下命令:

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


要运行,请使用docker-compose up -d

10-07 19:00
查看更多