Filestash is a self-hosted web-based file management system that provides an elegant solution for managing files on your server. In this tutorial, we will guide you through the steps to install Filestash on NixOS.
Prerequisites:
Before you start with the installation, make sure you have the following:
First, we need to install the Nixpkgs package manager on our system. Follow the below command to install it:
sudo nix-env -i nixpkgs
Once the Nixpkgs package manager is installed, we can now proceed to install Filestash from Nixpkgs. Follow the command given below to install the latest version of Filestash:
sudo nix-env -i filestash
After installation, we need to configure Filestash to work properly. Filestash uses a YAML configuration file to define settings. We will create this configuration file in the "filestash" directory.
sudo mkdir /etc/nixos/filestash
sudo nano /etc/nixos/filestash/config.yml
Paste the following code in the editor:
filestash:
server:
http-listen: ":8334"
This YAML configuration file specifies the port number to use when running the Filestash server. You can change the port number according to your needs.
Once the configuration is done, we can start our Filestash server by running the following command:
sudo filestash start
This will start the Filestash server, and you can access it by opening a web browser and typing the following URL:
http://<your-server-ip>:8334/
By default, the Filestash server is running without any authentication. This is a security risk. We can secure our server by adding authentication. Follow the below steps to add authentication:
sudo nix-env -i nginx
sudo nano /etc/nginx/sites-available/filestash
server {
listen 80;
server_name <your-server-ip>;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name <your-server-ip>;
ssl_certificate /etc/ssl/certs/<your-certificate>;
ssl_certificate_key /etc/ssl/private/<your-key>;
location / {
proxy_pass http://localhost:8334/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}
This Nginx configuration file redirects all HTTP requests to HTTPS and proxies requests to the Filestash server. We have also added authentication by specifying an auth_basic directive and creating an .htpasswd file.
sudo apt-get install apache2-utils
sudo htpasswd -c /etc/nginx/.htpasswd your-username
sudo nginx -t
sudo systemctl restart nginx
Now, your Filestash server should be accessible with authentication at the following URL:
https://<your-server-ip>/
Congratulations! You have successfully installed and secured Filestash on your NixOS system. Now you can easily manage and share files with your team or clients.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!