Skip to content

Instantly share code, notes, and snippets.

@aenniw
Last active February 23, 2018 09:35
Show Gist options
  • Save aenniw/965f6cd6ff172fdb635567440c091c5e to your computer and use it in GitHub Desktop.
Save aenniw/965f6cd6ff172fdb635567440c091c5e to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage: USER=user PASSWD=secret volumio2-ui-basic-auth.sh or
# volumio2-ui-basic-auth.sh for default user volumio:volumio
sudo su || exit 1
apt-get install apache2-utils nginx
htpasswd -cb /etc/nginx/.htpasswd ${USER:-volumio} ${PASSWD:-volumio}
rm /etc/nginx/sites-enabled/default
echo '
server {
listen 80;
location / {
proxy_pass http://0.0.0.0:3000;
include /etc/nginx/proxy_params;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
}
}
' > /etc/nginx/sites-enabled/volumio.local
head -n -1 /etc/rc.local > /etc/rc.local.new && mv /etc/rc.local.new /etc/rc.local
echo '
for i in $( iptables -t nat --line-numbers -L | grep ^[0-9] | awk '"'"'{ print $1 }'"'"' | tac ); do iptables -t nat -D PREROUTING $i; done
mkdir -p /var/log/nginx/
service nginx restart
exit 0
' >> /etc/rc.local
chmod +x /etc/rc.local
/etc/rc.local
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment