[5 Mins Docker] Create Paste & File Share Site with API Support in Command Line – Linx-Server
GitHub Project Linx-server is a self-hosted file/media sharing website project which you can use it to develop a temporary website to store your files or texts and share them to the world. I had other posts to introduct similar service such as transfer.sh or microbin. For this project, one of most interesting features is you can use command line to call the APi then upload files, which make it a best alternative for transfer.sh (transfer.sh site is down now). Transfer.sh project is at https://github.com/dutchcoders/transfer.sh, which you will be still able to use it to create your own site.
In this post, I will show you how to quickly deploy Linx-server to your VPS and how you can use this Linx-server.
Based on Github, the main features for Linx-server are:
- Display common filetypes (image, video, audio, markdown, pdf)
- Display syntax-highlighted code with in-place editing
- Documented API with keys for restricting uploads
- Torrent download of files using web seeding
- File expiry, deletion key, file access key, and random filename options
Github: https://github.com/andreimarcu/linx-server
Screenshots
- https://put.icu/
- https://linx.51sec.org
Installation Pre-requirements
Free resources you might need to complete this docker project:
- Server: Oracle Free VPS, Azure Free VPS, Google Cloud Free VPS, and others
- Create a Free Tier Windows/Linux Azure VPS VM
- [Free VPS] GCP (Google Cloud Platform) Tips and Tricks (Free 16G RAM, 4 vCPU VPS)
- System: Cloud Vendor Ubuntu, Debian, or DD an original version
- SWAP size increase:
- wget https://raw.githubusercontent.com/51sec/swap/main/swap.sh && bash swap.sh
- Enable Password ssh login
- Enable BBR
- systemctl restart docker
- Domain: (Optional) EU.ORG to get a free one, free Cloudflare account to manage your domain
- Confirm port has not been used (you might need to install lsof using command : apt install lsof):
- lsof -i:8088
- Check cpu & memory info
- lscpu
- cat /proc/cpuinfo
- htop / top / free
Pre-installed services:
- Docker,
- apt update
- apt install docker.io
- apt install docker-compose
- apt upgrade docker.io
- mkdir /root/data/docker_data/<docker_name>
- Docker-Compose (Using Ubuntu OS for the commands)
- Docker-compose down
- Optional command : use following command to backup your Docker data. You might need to change your folder name based on your docker configuraiton
- cp -r /root/data/docker_data/<docker_name> /root/data/docker_data_backup/<docker_name>
- docker-compose pull
- docker-compose up -d
- docker image prune
- Portainer (Optional)
- docker volume create portainer_data
- docker run -d -p 9000:9000 --name portainer --restart always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
- Install some applications: apt install wget curl sudo vim git (Optional)
- aapanel with Nginx (Optional)
- Nginx Proxy Manager (Optional)
- Install screen (Optional)
- Install screen (Depends on the Linux Distribution if it came pre installed or not) : yum install screen
- Initiate a Screen : screen or screen -S <screen name> <command to execute>
- Detach from the screen : "CTRL+A,D" not "CTRL+A+D"
- List all the screen currently working : screen -ls
- Reattach to a screen : screen -r <session number> or screen -r <screen name>
- Kill specific screen: screen -X -S <screen name> quit
- Kill all screens : pkill screen
- Monitoring Usage
- Docker stats
Steps
1 Create folders and modify folder permissions
- mkdir /root/files
- mkdir /root/meta
- chown -R 65534:65534 meta && chown -R 65534:65534 files
2 Create configuration file
bind = 127.0.0.1:80 sitename = NetSec Linx siteurl = http://<Server IP:Port>/ selifpath = s maxsize = 4294967296 maxexpiry = 86400 allowhotlink = true remoteuploads = true nologs = true force-random-filename = false cleanup-every-minutes = 5
Option | Description |
---|---|
bind = 127.0.0.1:8080 |
what to bind to (default is 127.0.0.1:8080) |
sitename = myLinx |
the site name displayed on top (default is inferred from Host header) |
siteurl = https://mylinx.example.org/ |
the site url (default is inferred from execution context) |
selifpath = selif |
path relative to site base url (the "selif" in mylinx.example.org/selif/image.jpg) where files are accessed directly (default: selif) |
maxsize = 4294967296 |
maximum upload file size in bytes (default 4GB) |
maxexpiry = 86400 |
maximum expiration time in seconds (default is 0, which is no expiry) |
allowhotlink = true |
Allow file hotlinking |
contentsecuritypolicy = "..." |
Content-Security-Policy header for pages (default is "default-src 'self'; img-src 'self' data:; style-src 'self' 'unsafe-inline'; frame-ancestors 'self';") |
filecontentsecuritypolicy = "..." |
Content-Security-Policy header for files (default is "default-src 'none'; img-src 'self'; object-src 'self'; media-src 'self'; style-src 'self' 'unsafe-inline'; frame-ancestors 'self';") |
refererpolicy = "..." |
Referrer-Policy header for pages (default is "same-origin") |
filereferrerpolicy = "..." |
Referrer-Policy header for files (default is "same-origin") |
xframeoptions = "..." |
X-Frame-Options header (default is "SAMEORIGIN") |
remoteuploads = true |
(optionally) enable remote uploads (/upload?url=https://...) |
nologs = true |
(optionally) disable request logs in stdout |
force-random-filename = true |
(optionally) force the use of random filenames |
custompagespath = custom_pages/ |
(optionally) specify path to directory containing markdown pages (must end in .md) that will be added to the site navigation (this can be useful for providing contact/support information and so on). For example, custom_pages/My_Page.md will become My Page in the site navigation |
3 One Line Command to bring Docker Up
docker run -d -p 80:8080 -v /root/linx-server.conf:/data/linx-server.conf -v /root/meta:/data/meta -v /root/files:/data/files andreimarcu/linx-server -config /data/linx-server.conf
4 Using docker-compose
Example with docker-compose
version: '2.2' services: linx-server: container_name: linx-server image: andreimarcu/linx-server command: -config /data/linx-server.conf volumes: - /path/to/files:/data/files - /path/to/meta:/data/meta - /path/to/linx-server.conf:/data/linx-server.conf network_mode: bridge ports: - "80:8080" restart: unless-stopped
Using NPM To Handle TLS Certificate
Related Posts:
共有 0 条评论