Wednesday, May 8, 2019

Password protecting in tensorboard UI

Tensorflow comes with handy tool i.e. tensorboard.

Using tensorboard it is easier to monitor loss(%),Prediction,Histogram and distribution in real time.And this save time from writing code for plotting such graph.

To view these graph in UI;it is needed to run tensorboard command.

This UI is accessible by URL that will be printed when you run tensorboard command.But this UI is not password protected.

To password protect UI access needed to perform following steps

1)Configure nginx as a reverse proxy

for doing so it is needed to do following configuration changes in nginx

        location / {
                    rewrite ^/tensorflow(.*) /$1 break;
                    proxy_pass http://127.0.0.1:6006/;
        }

After doing this when you access http://<IP/domain> it will show the tensorboard output UI.
Follow next steps to

2)Configure htpasswd file
#sudo sh -c "echo -n 'sandeep:' >> /etc/nginx/.htpasswd"

## sudo sh -c "openssl passwd -apr1 >> /etc/nginx/.htpasswd"
Password: <Enter password>
Verifying - Password: <Enter same password>


3)Do changes in nginx configuration

        location / {
                    auth_basic "Restricted Content";
                    auth_basic_user_file /etc/nginx/.htpasswd;
                    rewrite ^/tensorflow(.*) /$1 break;
                    proxy_pass http://127.0.0.1:6006/;
        }

4)Restart nginx

5)Run tensorboard command
#tensorboard --log-dir=tf_log_output

6)Open following URL in webbrowser
http://<IP/Domain>