33# Save this script in one of your shares and schedule it to run as root at boot
44# through Control Panel -> Task Scheduler
55# DSM upgrades will reset these changes, which is why we schedule them to happen automatically
6- # Set the variables below if you want to customise the ports which DSM will listen on instead
7- # NOTE: These ports are used for some services, e.g. Photo Station
86
9- # NGINX Ports
10- # Several Synology services use port 80 and 443 via Nginx. This conflicts with Traefik.
11- # This script reconfigures Nginx to use 81 and 444 instead, leaving ports 80 and 443 free for Traefik to use.
12- HTTP_PORT=81
13- HTTPS_PORT=444
14- sed -i " s/^\( *listen .*\)80/\1$HTTP_PORT /" /usr/syno/share/nginx/* .mustache || { echo " Switching HTTP port to 81 failed." ; exit 1; }
15- sed -i " s/^\( *listen .*\)443/\1$HTTPS_PORT /" /usr/syno/share/nginx/* .mustache || { echo " Switching HTTPS port to 444 failed." ; exit 1; }
7+ # NGINX Ports - CUSTOMIZE THIS
8+ # Several Synology services use port 80 and 443 via Nginx. This conflicts with Traefik, Nginx Proxy Manager, Caddy, etc.
9+ # This script reconfigures Nginx to use non-default ports, leaving ports 80 and 443 free for reverse proxy.
1610
17- synosystemctl restart nginx
11+ DEFAULT_HTTP_PORT=80 # typically left as-is, 80.
12+ DEFAULT_HTTPS_PORT=443 # typically left as-is, 443.
13+ NEW_HTTP_PORT=81
14+ NEW_HTTPS_PORT=444
15+
16+ # ############### DO NOT EDIT BEYOND THIS LINE ###########################
17+ sed -i " s/^\([ \t]\+listen[ \t]\+[]:[]*\)$DEFAULT_HTTP_PORT \([^0-9]\)/\1$NEW_HTTP_PORT \2/" /usr/syno/share/nginx/* .mustache
18+ sed -i " s/^\([ \t]\+listen[ \t]\+[]:[]*\)$DEFAULT_HTTPS_PORT \([^0-9]\)/\1$NEW_HTTPS_PORT \2/" /usr/syno/share/nginx/* .mustache
1819
19- # MYSQL/MARIADB
20- # Disabled because I do not use the Synology MariaDB package. Instead, I use MariaDB on docker. See docker-compose-t2-synology.yml.
21- # MYSQL_DEF_PORT=3307
22- # MYSQL_NEW_PORT=3306
23- # MY_CNF1="/usr/local/mariadb10/etc/mysql/my.cnf"
24- # MY_CNF2="/volume1/@appstore/MariaDB10/usr/local/mariadb10/etc/mysql/my.cnf"
25- # sed -i "s@port = $MYSQL_DEF_PORT@port = $MYSQL_NEW_PORT@g" "$MY_CNF1" || { echo "Replacing in CNF1 failed." ; exit 1; }
26- # sed -i "s@port = $MYSQL_DEF_PORT@port = $MYSQL_NEW_PORT@g" "$MY_CNF2" || { echo "Replacing in CNF2 failed." ; exit 1; }
20+ synosystemctl restart nginx
0 commit comments