From 55057f02eeed339f38286bd92010755704eb3717 Mon Sep 17 00:00:00 2001 From: Benjamin Sanders Date: Fri, 18 Sep 2026 10:05:21 -0400 Subject: added three files --- bsimg-process.sh | 12 ++++++++++++ configure-server.sh | 26 ++++++++++++++++++++++++++ pbs-bsimg-net.conf | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 bsimg-process.sh create mode 100644 configure-server.sh create mode 100644 pbs-bsimg-net.conf diff --git a/bsimg-process.sh b/bsimg-process.sh new file mode 100644 index 0000000..48346d7 --- /dev/null +++ b/bsimg-process.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -euo pipefail + +DIR="$1" +HASH="$2" +EXT="$3" + +cd "$DIR" +for size in thumb:200 medium:800 large:1600; do + name="${size%%:*}"; px="${size##*:}" + magick "${HASH}-original.${EXT}" -resize "${px}x${px}>" "${HASH}-${name}.jpg" +done \ No newline at end of file diff --git a/configure-server.sh b/configure-server.sh new file mode 100644 index 0000000..31bea65 --- /dev/null +++ b/configure-server.sh @@ -0,0 +1,26 @@ +# This is a rudimentary script to configure an image node + +# Start by updating cache and installing needed packages +sudo apt update && sudo apt install imagemagick nginx vim git sudo python3-certbot-nginx -y + +# Created needed configuration files +# First the NGINX config file +# Second the file to process images +touch /etc/nginx/conf.d/pbs-bsimg-net.conf +touch /usr/local/bin/bsimg-process.sh + +# Make the image processor file executable +chmod +x /usr/local/bin/bsimg-process.sh + +# Add my username to the www-data and ensure the group owns the directory +# so I can upload files +usermod -aG www-data ben +usermod -aG sudo ben +chown -R www-data:www-data /var/www/html/ + +# Attempt to get TLS certs +# Replace {region} with state/country code of region the vm is located +certbot -d bsimg.net -d pbs.atl.bsimg.net -d pbs.bsimg.net -d pbs.{region}.bsimg.net + +# Restart NGINX +systemctl restart nginx.service \ No newline at end of file diff --git a/pbs-bsimg-net.conf b/pbs-bsimg-net.conf new file mode 100644 index 0000000..69cf4bb --- /dev/null +++ b/pbs-bsimg-net.conf @@ -0,0 +1,35 @@ +# Default server configuration +map $arg_name $img_name { + default $arg_name; + "" "missing"; +} + +map $arg_format $img_format { + default $arg_format; + "" "missing"; +} + +server { + listen 80; + listen [::]:80; + + root /var/www/html; + + index index.html; + + server_name pbs.bsimg.net pbs.atl.bsimg.net bsimg.net; + + error_page 404 /404.html; + error_page 500 /500.html; + + location / { + try_files $uri $uri/ =404; + } + + location /media/ { + root /var/www/html; + expires 1y; + add_header Cache-Control "public, immutable"; + try_files $uri-${img_name}.${img_format} =404; + } +} \ No newline at end of file -- cgit v1.2.3