Scripts

I use the nginx as a reverse proxy on the synology box. The advantage is I can use ssl/https to connect to the reverse proxy where it terminates and then forward the connection to the given "backend" server. This way I can use the 443 port for connecting to all my servers. The difference is only in the URL which I use. So for example normally if I would like to directly connect to the mlnet webGUI I would use a URL like this http://www.whatever-you-wa.nt:4080/ but after using the nginx the URL gets "simple" like http://www.whatever-you-wa.nt/mldonkey/ such a solution must not work always like in case of the mt-daap/applerecords applet which hardcodes the URL.

PATH='/opt/bin:/opt/sbin:/usr/sbin:/bin:/usr/bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/syno/bin:/usr/syno/sbin:/usr/local/bin:/usr/local/sbin'
# Location of the chroot
CHROOT=/volume1/public/debian/chroottarget
# Now on to usual bussines
NGINX=/usr/local/nginx/sbin/nginx
NAME=S90nginx
DESC="nginx reverse proxy"
RUNNGINX=no
PIDFILE=/var/run/nginx.pid
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /opt/etc/default/$NAME ] ; then
    . /opt/etc/default/$NAME
fi
if [ "$RUNNGINX" != "yes" ];then
  echo "$NAME not to be started. Edit /opt/etc/default/$NAME first."
  exit 1
fi
set -e
case "$1" in
  start)
    echo -n "Starting $DESC: "
    chroot $CHROOT /bin/bash -c "mount -t proc none /proc;$NGINX > /dev/null 2>&1 &"
    echo "$NAME."
  ;;
  stop)
    echo -n "Stopping $DESC: "
    cat $CHROOT$PIDFILE|xargs kill -9
    echo "$NAME."
  ;;
  restart|force-reload)
    echo -n "Restarting $DESC: "
    cat $CHROOT$PIDFILE|xargs kill -9
    sleep 1
    chroot $CHROOT /bin/bash -c "mount -t proc none /proc;$NGINX > /dev/null 2>&1 &"
    echo "$NAME."
  ;;
  *)
    N=/opt/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|force-reload}" >&2
    exit 1
  ;;
esac
exit 0
  • Oh well another point is the certificate. I didn't took the time to make one for myself so I am stuck with using the synology supplied one. But this may eventually change. Isn't a big deal.
  • Another thing is the mount -t proc none /proc command out there. If this script is invoked several times then the ds complains because /proc is already there. Up till now I haven't seen any ill effects. So case closed for now.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.