Very simple server that supports settings and gettings public arbitrary strings of text (limited to 16KB).
This project is utilized in https://github.com/Ar-Kareem/PythonDiceWeb
This server should be incredibally easy to setup with few commands below (using docker).
This project uses three docker containers:
-
Reverse Proxy: Traefik [ports are exposed to internet]
-
The server: nginx + uwsgi + Python Flask [nginx implements rate limiting per ip]
-
Database: Redis
git clone https://github.com/Ar-Kareem/progshare.git
cd progshare
chmod +x ./init.sh
./init.sh
source ./venv/bin/activate
docker compose up --build --remove-orphans --force-recreate -d
# (if you want the local redis port open)
# docker compose -f docker-compose.yml -f docker-compose-redisport.yml up --build --remove-orphans --force-recreate -d
If healthcheck_ssl.sh returns Is Alive: yes then the containers are running and accessible to the public.
Otherwise run ./trace_domain.sh to diagnose DNS issues and/or read the sections below.
- All above commands ran successfully (will need docker installed)
- The domain
$DOMAINin the./.envfile points to the machine running the docker container (both ports80and443).- Example for home-server using sqaurespace domain:
- Go to squarespace
DNS Settingsand add aCustom recordwhich makes$DOMAINpoint to your ip - make sure your ip router forwards incoming traffic from ports
80and443to the static-ip of the device running the docker container. - To check run
chmod +x ./trace_domain.sh; ./trace_domain.shand make sure domain points to server-ip.
- Go to squarespace
- Example for home-server using sqaurespace domain:
(IGNORE SSL) Run below. should be Is Alive: yes.
chmod +x ./healthcheck.sh ; ./healthcheck.sh
(ENSURE SSL IS ON) Run below. should be Is Alive: yes.
chmod +x ./healthcheck_ssl.sh ; ./healthcheck_ssl.sh
If ./healthcheck_ssl.sh returns Is Alive: yes then the containers are running and accessible to the public.
You should periodically run the .sh or .ps script in ./db_backups/ to make backups of the redis database.
You should check logs to make sure no critical errors happened. Run the following and look at the output:
chmod +x tail_logs.sh; ./tail_logs.sh
vscode can view DB if you ssh into the server and connect to redis using Database Client JDBC extension.
RSYNC DB from pi:
rsync -r --rsync-path="sudo rsync" [email protected]:/home/master/progshare/redis/dump.rdb ./dump.rdb
RSYNC directory from pi: (shouldn't need to use this)
rsync -r --exclude "venv" --exclude ".git" --rsync-path="sudo rsync" [email protected]:/home/master/progshare/ ./progshare/
Check which docker containers are running: docker ps
stop and remove containers: docker compose down
stop -> pull -> start:
docker compose stop; git pull; docker compose -f docker-compose.yml -f docker-compose-redisport.yml up --build --remove-orphans --force-recreate -d
needed if volumes change:
docker-compose rm
for dev:
docker compose -f ./docker-compose.yml -f ./docker-compose-dev.yml up --build --remove-orphans --force-recreate
for redis cli:
docker exec -it redis redis-cli -p 4721
to edit redis .conf, need to own the file first:
sudo chown master ./redis/redis.conf
to delete all logs
chmod +x rm_logs.sh; sudo ./rm_logs.sh