Skip to content

Commit

Permalink
Add a public www server on :7998.
Browse files Browse the repository at this point in the history
  • Loading branch information
carboxylman committed Sep 19, 2020
1 parent 71b3317 commit 92e65ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
2 changes: 2 additions & 0 deletions setup-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ DIRNAME=`dirname $0`
# Setup our core vars
#
OURDIR=/local/setup
WWWPRIV=$OURDIR
WWWPUB=/local/profile-public
SETTINGS=$OURDIR/settings
LOCALSETTINGS=$OURDIR/settings.local
TOPOMAP=$OURDIR/topomap
Expand Down
41 changes: 32 additions & 9 deletions setup-nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,51 @@ echo "$ADMIN_PASS" | htpasswd -n -i admin | $SUDO tee -a /etc/nginx/htpasswd
$SUDO chown www-data:root /etc/nginx/htpasswd
$SUDO chmod 660 /etc/nginx/htpasswd

$SUDO mkdir /var/www/profile-setup
$SUDO chown www-data /var/www/profile-setup
$SUDO mount -o bind,ro $OURDIR /var/www/profile-setup/
echo $OURDIR /var/www/profile-setup none defaults,bind 0 0 | $SUDO tee -a /etc/fstab
cat <<EOF | $SUDO tee /etc/nginx/sites-available/profile-setup-logs
$SUDO mkdir /var/www/profile-private
$SUDO chown www-data /var/www/profile-private
$SUDO mount -o bind,ro $WWWPRIV /var/www/profile-private/
echo $WWWPRIV /var/www/profile-private none defaults,bind 0 0 | $SUDO tee -a /etc/fstab
cat <<EOF | $SUDO tee /etc/nginx/sites-available/profile-private
server {
include /etc/nginx/mime.types;
types { text/plain log; }
listen 7999 default_server;
listen [::]:7999 default_server;
root /var/www/profile-setup;
root /var/www/profile-private;
index index.html;
server_name _;
location / {
autoindex on;
auth_basic "profile-setup";
auth_basic "profile-private";
auth_basic_user_file /etc/nginx/htpasswd;
}
}
EOF
$SUDO ln -s /etc/nginx/sites-available/profile-setup-logs \
/etc/nginx/sites-enabled/profile-setup-logs
$SUDO ln -s /etc/nginx/sites-available/profile-private \
/etc/nginx/sites-enabled/profile-private

$SUDO mkdir -p /local/profile-public
$SUDO chown $SWAPPER /local/profile-public
$SUDO mkdir /var/www/profile-public
$SUDO chown www-data /var/www/profile-public
$SUDO mount -o bind,ro $WWWPUB /var/www/profile-public/
echo $WWWPUB /var/www/profile-public none defaults,bind 0 0 | $SUDO tee -a /etc/fstab
cat <<EOF | $SUDO tee /etc/nginx/sites-available/profile-public
server {
include /etc/nginx/mime.types;
types { text/plain log; }
listen 7998 default_server;
listen [::]:7998 default_server;
root /var/www/profile-public;
index index.html;
server_name _;
location / {
autoindex on;
}
}
EOF
$SUDO ln -s /etc/nginx/sites-available/profile-public \
/etc/nginx/sites-enabled/profile-public
service_enable nginx
service_restart nginx

Expand Down

0 comments on commit 92e65ee

Please sign in to comment.