Task:
Install Filegator 8 on Ubuntu 24.
Environment:
- VM - 2 CPU, 8 GM RAM, 500 GB
- mwfiles.mindwatering.net / 10.0.69.109
- sudo admin user: myadminid
- filegator user: mwfiles
- service name: mwfiles
- repository location: /local/share/
Steps:
1. Template has DHCP enabled, login vi remote console and set to static IP and new name.
a. Using remote console, log in:
- myadminid
- <starting template pwd>
b. Change the template password:
$ passwd
<enter new password>
<enter/confirm new password>
c. Set newly deploy Ubuntu template to static IP:
$ sudo apt-get install vim
<y, and wait>
$ cd /etc/netplan
$ ls
$ vi 50-cloud-init.yaml
network:
ethernets:
ens160:
dhcp4: no
dhcp6: no
addresses: [10.0.69.109/24]
routes:
- to: default
via: 10.0.69.1
nameservers:
addresses: [10.0.69.1, 10.0.69.2]
version: 2
<esc>:wq (to save)
$ sudo netplan apply
<no output is success>
d. Set the hostname:
$ sudo hostnamectl set-hostname mwfiles
$ sudo hostnamectl
<confirm output>
e. Edit /etc/hosts and change/confirm IP and add new mwfiles name if needed:
$ sudo vi /etc/hosts
e.g.
...
127.0.1.1 localhost.local mwfiles
...
10.0.69.109 mwfiles mwfiles.mindwatering.net
f. Close remote console.
2. Install pre-requisites:
a. Login:
$ ssh myadminid@mwfiles.mindwatering.net
<enter pwd if not private key>
b. Install pre-requisites and useful utilities:
$ sudo apt-get install iputils-ping wget unzip git golang-go build-essential
c. Create Filegator user:
$ sudo useradd --system --no-create-home --shell /usr/sbin/nologin mwfiles
d. Create Filegator program directory:
$ sudo mkdir /opt/filegator
e. If not using the /opt/filegator repository folder, create desired repository folder:
$ sudo mkdir /local/
$ sudo mkdir /local/share
3. Download and prep Filegator for Build:
a. Download the Filegator repository v8 branch:
$ cd /home/myadminid/
$ wget https://github.com/filegator/filegator/archive/refs/heads/v8.zip
or
(github.com/<username>/<repository>/archive/<branch>.zip)
or
$ git clone ...
b. Uncompress:
$ unzip filegator-8.zip && rm *.zip
<wait>
$ ls -l
<view new git repo files>
c. Move to program folder created:
$ cd filegator-8
$ mv * /opt/filegator
d. Change ownership of the files to the Filegator service account.
Note:
- For simplicity, we have left the source files. After build they can be cleaned up.
- Not all the files need to be changed to the mwfiles service account, just the ones in the private and bin folder and repository folders (./repository or /local/share).
$ sudo chown -R mwfiles:mwfiles /opt/filegator/bin
$ sudo chown -R mwfiles:mwfiles /opt/filegator/private
$ sudo chown -R mwfiles:mwfiles /opt/filegator/repository
$ sudo chown -R mwfiles:mwfiles /local/
4. Build the binary:
a. Make/build the binary:
$ cd /opt/filegator/
$ sudo make build
or
$ sudo go build -mod=vendor -o bin/filegator
b. Change the ownership to the service account again:
$ sudo chown -R mwfiles:mwfiles /opt/filegator/bin
5. Verify the build works by running manually:
Notes:
- The default administrative account is: admin
- The default password is: admin123
- If you are building your VM/VPS in the public cloud and it already is accessible, you can use command before starting:
FILEGATOR_ADMIN_PASSWORD="$(cat /home/myadmin/secrets/filegator_admin_pwd.txt)"
$ ./bin/filegator -addr 10.0.69.109:8080
<the command prompt will be unavailabe while Filegator is running. Used <cntrl><c> to send the quit to Filegator>
6. Create the systemd service, enable, and verify:
Note:
- This version provides logging to the /var/log/filegator location, but in the administrative UI, it can be swapped to use the /opt/filegator/private/logs/ location.
a. Create mwfiles.service:
$ sudo vi /lib/systemd/system/mwfiles.service
[Unit]
Description=MW-Files
ConditionPathExists=/opt/filegator/
After=network.target
[Service]
Type=simple
User=mwfiles
Group=mwfiles
LimitNOFILE=20480
Restart=on-failure
RestartSec=10
WorkingDirectory=/opt/filegator
ExecStart=/opt/filegator/bin/filegator -addr 10.0.69.109:8080
ExecReload=/bin/kill -HUP $MAINID
StandardOutput=append:/var/log/filegator/log.log
StardardError=append:/var/log/filegator/error.log
MemoryMax=4096M
CPUQuota=80%
[Install]
WantedBy=multi-user.target
b. Make the log folder:
$ sudo mkdir /var/log/filegator
c. Reload the daemon so the change can be seen w/o a reboot:
$ sudo systemctl daemon-reload
d. Enable the service:
$ sudo systemctl enable mwfiles.service
e. Start the service and verify
$ sudo systemctl start mwfiles.service
<verify no failure>
$ sudo systemctl status mwfiles.service
<verify that started okay and running on port 8080>
7. Change the default admin password, add users, and setup the repository
a. Login:
Address (http): 10.0.69.109:8080
ID: admin
Password: admin123
b. Update Users:
a. Navigate to Users view:
- Setup (top menu) --> Users
b. Change admin password:
- On admin row, click Set password
- Under New password, enter the <new-secure-password>. Click Save (button).
c. Create another admin user for the administrator, Nic:
- Click New user (button)
- In the form, enter:
- - Username: nic
- - Name: Nic Doe
- - Password: <new-secure-password>
- - Role: Admin
- - Home: /
- - Create home folder if it does not exist: <leave checked or uncheck, doesn't matter>
- - Permissions: Read, Upload, Batchdownload, Chmod, Write, Download, Zip
- Click Create (button) to save.
d. Repeat and create normal users.
Note:
- Access is by folder.
- If someone has access to the root "/" folder, he or she will have the permissions access to all the folders.
- If someone has home folder, he/she doesn't even know the name of the home folder, he or she can only see the folders and files in that home folder.
e. Change the site/application name:
Note:
- There are other options on this page that should be reviewed for changes, as well.
- Setup (top menu) --> UI
- On the UI form:
- - Title: MW Files
- Click Save (button)
f. Set the File maximums:
- Setup (top menu) --> Files
- On the Files form:
- - Max upload size (MB): 400
- - Simultaneous uploads: 7
- Click Save (button)
g. Set the Repository location (to override from the /opt/filegator/repository location:
- Setup (top menu) --> Repository
- On the Repository form:
- - Files are managed in this location. Switching applies immediately:
- - Storage type: Local folder
- - Folder: /local/share
- Click Save (button)
h. (optional) Set additional logging w/in the /opt/filegator/private/logs/ folder:
Note:
- Once this site is HTTPS secure, there will be other fields to change here.
- If you set an external location to the /opt/filezilla/ path, the location must be owned with rw access to the mwfiles user (e.g. /var/log/filegator/app.log)
- Setup (top menu) --> Security
- On the Security form:
- - Write an event log: <check>
- - Log file: private/logs/app.log
- Click Save (button)
---
Use Apache Reverse Proxy on Same VM for TLS:
1. Install apache and configure:
a. Login:
$ ssh myadminid@mwfiles.mindwatering.net
<enter pwd if not private key>
b. Install Apache:
$ sudo apt-get install apache2
<y, and wait>
c. Enable needed modules:
$ sudo a2enmod proxy
$ sudo a2enmod proxy_http
$ sudo a2enmod ssl
$ sudo a2enmod rewrite
d. Disable the default site:
$ sudo a2dissite 000-default.conf
$ sudo systemctl stop apache2
2. Install certbot for LetsEncrypt:
Note:
- Certbot path: /etc/letsencrypt/live/mwfiles.mindwatering.net/
a. Install certbot:
$ sudo apt-get install certbot python3-certbot-apache
<y, and wait>
b. Wait to run certbot until apache running.
3. Create the Apache mwfiles site config and start:
Note:
- Certbot path: /etc/letsencrypt/live/mwfiles.mindwatering.net/
- Lines 12, any is required for websockets; line 18, as well
- SSL lines commented out since certbot has not run yet
a. Create mwfiles.conf and mwimages.conf:
$ sudo vi /etc/apache2/sites-available/mwfiles.conf
# Redirect HTTP to HTTPS
ServerName crwrfiles.mindwatering.net
DocumentRoot /var/www/html
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/images(?:/|$) [NC]
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge(?:/|$)
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
ServerName crwrfiles.mindwatering.net
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPass /images/ !
ProxyPass / http://192.168.2.109:8080/
ProxyPassReverse / http://192.168.2.109:8080/
ProxyRequests Off
ProxyPreserveHost On
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC] !^/images(?:/|$)
RewriteCond %{HTTP:Upgrade} websocket [NC] !^/images(?:/|$)
RewriteRule /(.*) ws://192.168.2.109:8080/$1 [P,L]
SSLCertificateFile /etc/letsencrypt/live/crwrfiles.mindwatering.net/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/crwrfiles.mindwatering.net/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
$ sudo vi /etc/apache2/sites-available/mwimages.conf
Edit the /images/ folder except so we can locally hosts the logos:
Alias /images "/var/www/images/"
Order allow,deny
Allow from all
Require all granted
b. Enable the app and the images folders:
$ sudo a2ensite mwfiles.conf
<confirm enabled>
$ sudo a2ensite mwimages.conf
<confirm enabled>
c. Start Apache:
$ sudo systemctl start apache2
<confirm started w/o error>
d. Confirm site is started/running:
$ sudo systemctl status apache2
<confirm>
e. Run certbot:
Note:
- Has multiple prompts
$ sudo certbot --apache
<follow prompts>
- Email Address: mwadminid@mindwatering.net
- Terms: Y
- Campaigns: Y ( or N)
- Which names: <blank for all>
(1. mwfiles.mindwatering.com)
<wait>
f. Verify Filegator working in browser.
---
Old code:
# Redirect HTTP to HTTPS
ServerName mwfiles.mindwatering.net
ServerAlias *.mwfiles.mindwatering.net
Redirect permanent / https://mwfiles.mindwatering.net/
ServerName mwfiles.mindwatering.net
ServerAlias *.mwfiles.mindwatering.net
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPass / http://10.0.69.109:8080/ upgrade=any
ProxyPassReverse / http://10.0.69.109:8080/
ProxyRequests Off
ProxyPreserveHost On
RewriteEngine On
RewriteCond %{HTTP:Connection} Upgrade [NC]
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteRule /(.*) ws://10.0.69.109:8080/$1 [P,L]
#SSLCertificateFile /etc/letsencrypt/live/mwfiles.mindwatering.net/fullchain.pem
#SSLCertificateKeyFile /etc/letsencrypt/live/mwfiles.mindwatering.net/privkey.pem
previous page
|