Skip to main content
Free ports 80 and 443 on Synology NAS

Free ports 80 and 443 on Synology NAS

·347 words·2 mins·
Photo by Jan Antonin Kolar on Unsplash

This guide explains how to free up ports 80 and 443 on your Synology NAS by reconfiguring the built-in Nginx service to use alternative ports. By default, Synology DSM uses these ports for various services, which can conflict with other applications like reverse proxies (e.g., Traefik, Nginx Proxy Manager, Caddy).

Let see how to change the Nginx ports safely and ensure the changes persist across reboots and DSM updates by scheduling a script to run at startup.

Check used ports
#

SSH into your Synology NAS as an administrator and run the following commands to check ports 80 and 443 usage:

sudo netstat -tulpn | grep '80\|443'
sudo grep -ri "listen 80" /usr/syno/share/nginx/
sudo grep -ri "listen 443" /usr/syno/share/nginx/

Backup default configuration
#

sudo cp -a /usr/syno/share/nginx /usr/syno/share/nginx_backup

Create ports remapping script
#

vi modify_dsm_nginx_ports.sh
#! /bin/bash

# Save this script in one of your shares and schedule it to run as root at boot
#   through Control Panel -> Task Scheduler
# DSM upgrades will reset these changes, which is why we schedule them to happen automatically

# NGINX Ports - CUSTOMIZE THIS
# Several Synology services use port 80 and 443 via Nginx. This conflicts with Traefik, Nginx Proxy Manager, Caddy, etc. 
# This script reconfigures Nginx to use non-default ports, leaving ports 80 and 443 free for reverse proxy.

DEFAULT_HTTP_PORT=80 # typically left as-is, 80.
DEFAULT_HTTPS_PORT=443 # typically left as-is, 443.
NEW_HTTP_PORT=8080
NEW_HTTPS_PORT=8443

################ DO NOT EDIT BEYOND THIS LINE ###########################
sed -i "s/^\([ \t]\+listen[ \t]\+[]:[]*\)$DEFAULT_HTTP_PORT\([^0-9]\)/\1$NEW_HTTP_PORT\2/" /usr/syno/share/nginx/*.mustache
sed -i "s/^\([ \t]\+listen[ \t]\+[]:[]*\)$DEFAULT_HTTPS_PORT\([^0-9]\)/\1$NEW_HTTPS_PORT\2/" /usr/syno/share/nginx/*.mustache

synosystemctl restart nginx

Run script
#

sudo bash /volume1/homes/greums/modify_dsm_nginx_ports.sh

Add root scheduled task at boot-up
#

  • Open Control Panel → Task Scheduler
  • Create → Scheduled Task → User-defined script
  • General tab:
    • Task: Modify DSM Nginx Ports
    • User: root
    • Event: Boot-up
  • Task Settings tab:
    • Run command: bash /volume1/homes/greums/modify_dsm_nginx_ports.sh
  • Save
  • Test by rebooting your NAS

Restore default configuration
#

If you need to revert the changes, restore the backup configuration:

sudo synosystemctl stop nginx
sudo rm -rf /usr/syno/share/nginx
sudo mv /usr/syno/share/nginx_backup /usr/syno/share/nginx
sudo synosystemctl restart nginx