Edit: For DSM 6, follow this: Reverse Proxy with DSM 6.0
I’ve upgraded my Synology DS 212+ to the latest DSM version, version 5, a few weeks ago.
Many things have changed on this new DSM version, and one of the things that changed, was the way Web station and Apache/PHP works.
The configuration files are different from the previous version 4 and they use now upstart to start and stop the service:
To stop the Web Station: /sbin/initctl stop httpd-user
To start the Web Station: /sbin/initctl start httpd-user
There is also a status command, to show the state of the server: httpd-user stop/waiting (Stopped) or httpd-user start/running, process #### (running)
For FileStation and Audio station, these application/sites normally expect the browser to connect to application ports, namely in my case the port 7000 and 7002. This has potentially two problems: I need to open them up on my home router to allow access, and sometimes I’m behind a proxy that doesn’t allow anything else to be used as a port on the url (except for port 80-HTTP or 443-HTTPS).
So I have these applications behind a reverse proxy on the WebStation. With this configuration I have my “normal” http address: http://primalcortex.somedomain.com and I also have http://filestation.primalcortex.somedomain.com and http://audio.primalcortex.somedomanin.com.
What is needed to achieve this? Well first a a dns server that accepts wirldcard domains. The Myds.me is one of them and is provided by Synology and directly integrated into the DSM.
Second a file like this is needed to be created:
<IfModule !proxy_module> LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_connect_module modules/mod_proxy_connect.so LoadModule proxy_http_module modules/mod_proxy_http.so </IfModule>
ProxyRequests Off #ProxyPreserveHost On
#For File Station <VirtualHost *:80> ServerName filestation.mydomainname.myds.me <Location /> RedirectPermanent / https://filestation.mydomainname.myds.me/ </Location> </VirtualHost>
<VirtualHost *:443> ServerName filestation.mydomainname.myds.me SSLCipherSuite HIGH:MEDIUM SSLProtocol all -SSLv2 SSLCertificateFile /usr/syno/etc/ssl/ssl.crt/server.crt SSLCertificateKeyFile /usr/syno/etc/ssl/ssl.key/server.key SSLEngine on SSLProxyEngine on ProxyRequests Off ProxyVia Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://localhost:7000/ ProxyPassReverse / http://localhost:7000/
(In case something is missing above due to WordPress formating issues see this ->
Save this file as httpd-FILESTATION-vh.conf-user at /usr/syno/etc
Then add the following line at the end of this file /etc/httpd/conf/httpd.conf-user
Repeat for other sites like Audio Station, changing the hostname and the localhost port.
You can now run the following command: /usr/syno/etc/rc.sysv/httpd-user-conf-writer.sh and check if the above include is added to the /etc/httpd/conf/httpd.conf file. This file is always regenerated at start of the Web Station.
Now we can restart the web station with /sbin/initctl stop httpd-user followed by the start command.
Check now if you can access the url: https://filestation.mydomain.myds.com
Edit: This works for version 5.0-4482
For more recent versions you need also to do the following:
Edit file /etc/httpd/conf/extra/httpd-ssl.conf-user and comment out the ServerName and ServerAlias like this
Save the files, write again the configuration (/usr/syno/etc/rc.sysv/httpd-user-conf-writer.sh), stop ( /sbin/initctl stop httpd-user) and start again ( /sbin/initctl start httpd-user), and it should work now.
Thanks for Markus (below at the comments for the solution) and Tensai for corrections.
EDIT: we can make all this setup to be done automatically, even between DSM upgrades. Thanks to Michi (see below) for his script: http://pastebin.com/raw.php?i=rjrU6X8K.
Just copy the content from the above link, and paste it into a file named, for example S99subdomains.sh in directory /usr/local/etc/rc.d
Make sure that the file is executable with the following command: chmod +x S99subdomains.sh and just run it: S99subdomains.sh start.
That’s it. Also just make sure that on DSM web interface the applications on Control Panel -> Application Portal have HTTP ports assigned that are coincident with those defined in the above file. Otherwise an Internal error 500 appear when trying to access the web page because Apache will try to forward the request to a non listening port.