Proxy Other Ports to Port 80 on Synology

Ok, so you want to be able to access services running on a random port on your Synology NAS over standard ports (80 and 443).  To do that, you need to do the following items:

  1. Enable the web station from the web services icon in control panel.  This gives you Apache
  2. Add the following lines to the end of /usr/syno/apache/conf/httpd.conf-user (you must re-do this after doing a DSM update).  Replace <accessPath> with a name, and <port> with the port it is running on.  For example, http://localhost:8080/party.
    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    ProxyRequests Off
    ProxyPreserveHost On
    
    <Location /<accessPath>>
    ProxyPass http://localhost:<port>/<accessPath>
    ProxyPassReverse http://localhost:<port>/<accessPath>
    </Location>
    
  3. Restart apache with “/usr/syno/etc.defaults/rc.d/S97apache-user.sh restart”

Just make sure whatever service you are doing this with has a base url of <accessPath>.

UPDATE:  Just updated to DSM 5.0 and a few things have changed:

  1. /usr/syno/apache/ has moved to /etc/httpd/
  2. /usr/syno/etc/rc.d/S97apache-user.sh is gone, so just use ‘httpd -k stop|start|restart’
  3. You may need to create the folder /var/services/web/internal for httpd to restart

Comments

4 responses to “Proxy Other Ports to Port 80 on Synology”

  1. spazlon Avatar
    spazlon

    I’m trying to set this up so I can access SABnzbd which is running on the NAS from outside my network. I only want to have 80 or 443 open, but SABnzbd runs on 8080.

    I added the code above to my httpd.conf-user file, but when I try to load the page I get, “Sorry, the page you are looking for is not found.”

    Any ideas?

  2. aaron Avatar
    aaron

    The following works for me.

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    ProxyRequests Off
    ProxyPreserveHost On


    ProxyPass http://localhost:8080/sabnzbd
    ProxyPassReverse http://localhost:8080/sabnzbd

  3. JT Avatar
    JT

    All working for me. Except there is a buggy part of this where the httpd.conf is reset on each reboot of the NAS. It has been advised that we should edit httpd.conf-sys, however I have yet to try it!

    1. aaron Avatar
      aaron

      I guess I don’t restart my NAS all that often, so I haven’t noticed if it gets reset or not. I think the only times I restart now are after an update!