Prevent default redirection from port 80 to 5000 on Synology NAS (DSM 5)

Backslash36 picture Backslash36 · May 23, 2015 · Viewed 19.8k times · Source

I would like to use a nginx front server on my Synology NAS for reverse-proxying pruposes. The goal is to provide a facade for the non-standard port numbers used by diverse webservers hosted the NAS. nginx should be listening on port 80, otherwise all this wouldn't make any sense.

However DSM comes out of the box with an Apache server that is already listening on port 80. What it does is really silly : it simply redirects to port 5000, which is the entry point to the NAS web manager (DSM).

What I would like to do is disable this functionality, making the port 80 available for my nginx server. How can I do this ?

Answer

koppor picture koppor · Apr 7, 2019

Since Google redirects to here also for recent Synology DSM, I answer for DSM6 (based on http://tonylawrence.com/posts/unix/synology/freeing-port-80/)

From DSM6, nginx is used as HTTP server and redirection place. The following commands will leave ngingx in place, put run it at port 8880 instead of 80.

  1. ssh into your Synology
  2. sudo -s
  3. cd /usr/syno/share/nginx
  4. Make a backup of server.mustache, DSM.mustache, WWWService.mustache
    • cp server.mustache server.mustache.bak
    • cp DSM.mustache DSM.mustache.bak
    • cp WWWService.mustache WWWService.mustache.bak
  5. sed -i "s/80/8880/g" server.mustache
  6. sed -i "s/80/8880/g" DSM.mustache
  7. sed -i "s/80/8880/g" WWWService.mustache
  8. Optionally, you can also move 443 to 8881:
    • sed -i "s/443/8881/g" server.mustache
    • sed -i "s/443/8881/g" DSM.mustache
    • sed -i "s/443/8881/g" WWWService.mustache
  9. Quit the shell (e.g., via Ctrl+D)
  10. Go to the Control Panel and change any setting (e.g. the Application portal -> Reverse Proxy to forward http://YOURSYNOLOGYHOSTNAME:80 to http://localhost:8181 - 8181 is the port suggested by the pi-hole on DSM tutorial).