Synology Port forwardding according to subdomain

Viewed 2711

In my router setting, I have set as following:

  • port 5000 - my synology disk station entry
  • port 1337 - my router panel

And I have set some subdomain to my external IP using DDNS:

  • wifi.example.com
  • disk.example.com
  • www.example.com

What I want to do is:

  • wifi.example.com redirect to port 1337 and go into router panel
  • disk.example.com redirect to port 5000 and go into synology panel
  • www.example.com go to synology web station server

I have tried set port 80 to my disk station in router setting, and want to do redirection in disk station via nginx or reverse proxy which provided by synology. However, I cannot find the nginx.conf in the synology. I tried set the reverse proxy but fail.

Can anyone provide me any clues for this? Appreciate for any help.

2 Answers

I think it must be possible...

  • unfortunateley it is not possible to specify a port with a DNS entry
  • but I think the setup you wish must be possible with nginx
  • the nginx configuration on the Synology is somewhat different
  • so when you setup wifi.example.com to your home ip-address
  • then you have to configure your router to port-foward port 80 to port 80 on your synology
    • on your synology you need to configure the www-station, so the nginx is really the backend. In my case it was first set to Apache
    • in the www-station you have to create a virtual host entry

enter image description here

  • after that you have to open a ssh session to your synology
  • and do a: cd /var/packages/WebStation/etc
  • the Nginx configuration is in the VirtualHost.json file
  • in this case you should see something like below:

    "eeb4adef-1fc5-4fd5-bacc-1fbd1e747d1c" : {

      "backend" : 0,
      "fqdn" : "wifi.example.com",
      "https" : {
         "compatibility" : 1,
         "compression" : false,
         "hsts" : false,
         "http2" : false,
         "redirect" : false
      },
      "index" : [ "index.html", "index.htm", "index.cgi", "index.php", "index.php5" ],
      "php" : 4,
      "port" : {
         "http" : [ 80 ],
         "https" : [ 443 ]
      },
      "root" : "/volume1/web/wiki"
    

    }, "version" : 2 }

now you can remove the "root" line and replace it with:

"return" : "301 http://someurl:1337$request_uri"

After this modification you will have to restart the WebStation service. And when you look with the Virtual Host in WebStation via DSM it will be now presented as AbNormal, but the redirect will (in my case) be working.

I hope this input is usefull for your question.

You can also try my solution:
redirect-http-to-https

  1. Set up a docker container for redirect.
  2. Then you can forword 80(with subdomain) to the docker port and forword 443 to the application port

This will not change any default setting which will avoid the potential problem.

Related