To restrict access to your nbdiff-web interface so that only you can see it, you can use HTTP Basic Authentication or a reverse proxy with authentication (like Nginx or Apache). Here’s how you can do it:
nbdiff-web with HTTP Basic AuthenticationIf nbdiff-web supports it, you can enable basic authentication directly in its configuration. Check if nbdiff-web has built-in options for username/password protection in its documentation.
If not, you can use a reverse proxy (recommended).
This is a common and secure approach.
If not already installed:
bashsudo apt update && sudo apt install nginx
Edit your Nginx configuration (e.g., /etc/nginx/sites-available/nbdiff-web):
nginxserver { listen 80; server_name your-server-domain-or-ip; location / { proxy_pass http://localhost:<nbdiff-web-port>; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; auth_basic "Restricted Access"; auth_basic_user_file /etc/nginx/.htpasswd; } }
Replace <nbdiff-web-port> with the port nbdiff-web is running on.
Install apache2-utils (for htpasswd):
bashsudo apt install apache2-utils
Create a password file and add a user (e.g., benjamin):
bashsudo htpasswd -c /etc/nginx/.htpasswd benjamin
You’ll be prompted to enter and confirm a password.
bashsudo nginx -t # Test configuration sudo systemctl reload nginx
Now, when you access http://your-server-domain-or-ip, you’ll be prompted for a username and password.
If you prefer Apache, the process is similar:
mod_proxy and mod_auth_basic.htpasswd.If you only want to allow your IP address to access the port, you can use ufw or iptables:
bashsudo ufw allow from <your-ip> to any port <nbdiff-web-port>
Replace <your-ip> and <nbdiff-web-port> accordingly.
Which option do you prefer? I can provide more detailed steps for your chosen method.