Discovery Explorer est un site web permettant d’exposer des dashboars Discovery . Voici une façon simple d’en sécuriser l’accès via du HTTPBasic Auth.
Nous allons exposer Discovery Explorer sous le path /dashboards.
Prérequis, Docker, DockerCompose et :
1 $ sudo apt install apache2-utils
D’abord, créons un fichier avec les users :
1 2 sudo htpasswd -c .htpasswd user1sudo htpasswd .htpasswd user2
Cela vous crée un fichier .htpasswd dont il faudra retenir le path.
Créez un fichier de conf pour NginX, nginx.conf :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 user www-data;worker_processes auto;pid /run/nginx.pid;include /etc/nginx/modules-enabled/*.conf ;events {worker_connections 768 ;} http { sendfile on ; tcp_nopush on ; types_hash_max_size 2048 ; include /etc/nginx/mime.types; default_type application/octet-stream; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3 ; ssl_prefer_server_ciphers on ; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error .log; gzip on ; server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; index index.html index.htm index.nginx-debian.html; server_name _; location / { try_files $uri $uri / =404 ; } location /dashboards { auth_basic "Restricted Content" ; auth_basic_user_file /etc/nginx/.htpasswd; proxy_pass http://discovery-explorer:3000; rewrite /dashboards/api/(.*) /api/$1 break ; proxy_set_header Host $host ; proxy_redirect off ; proxy_set_header X-Real-IP $remote_addr ; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ; } } }
Enfin créez un fichier docker-compose.yml :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 version: "3.9" services: discovery-explorer: image: warp10io/discovery-explorer:latest volumes: - /home/me/myDashboards:/data environment: - BASE_HREF=/dashboards/ nginx: image: nginx ports: - "80:80" volumes: - /home/me/nginx.conf:/etc/nginx/nginx.conf:ro - /home/me/.htpasswd:/etc/nginx/.htpasswd links: - discovery-explorer:discovery-explorer
Et y’a plus qu’a :
Vous pouvez admirer votre oeuvre sur http://localhost/dashboards .