!/bin/sh #You must change this variable to suit your hostname #---------------------------------------------------- URL="CHANGEME.COM " #The main URL of the site. For example CHANGEME.myds.me where CHANGEME is your domain. #---------------------------------------------------- #Clear your browsers cache!!! #Normally you do not have to change these variables httpconfig="/etc/httpd/conf/httpd.conf-user" startApache="/sbin/initctl start httpd-user" stopApache="/sbin/initctl stop httpd-user" redirectSubdomainTo() { #Create the Reverse Proxy File echo " 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 ProxyRequests Off #ProxyPreserveHost On #For Subdomain $1 NameVirtualHost *:80 ServerName $1.$URL RedirectPermanent / https://$1.$URL/ NameVirtualHost *:443 ServerName $1.$URL 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 Order deny,allow Allow from all ProxyPass / http://localhost:$2/ ProxyPassReverse / http://localhost:$2/ " > /usr/local/etc/httpd-"$1"-vh.conf-user if grep "/usr/local/etc/httpd-$1-vh.conf-user" $httpconfig; then /usr/syno/bin/synologset1 sys info 0x11800000 "subdomain $1 is running" else echo "Include /usr/local/etc/httpd-$1-vh.conf-user" >> $httpconfig /usr/syno/bin/synologset1 sys info 0x11800000 "Created subdomain $1" fi } case $1 in start) $stopApache sed -i 's/ ServerName/# ServerName/' /etc/httpd/conf/extra/httpd-ssl.conf-user sed -i 's/ ServerAlias/# ServerAlias/' /etc/httpd/conf/extra/httpd-ssl.conf-user #Usage: subdomain redirected port. So for example audio 8800 will redirect audio.mydomain.com to the internal 8800 port. redirectSubdomainTo audio 8800 redirectSubdomainTo dsm 5000 redirectSubdomainTo file 7000 redirectSubdomainTo note 9350 redirectSubdomainTo video 9007 /usr/syno/etc/rc.sysv/httpd-user-conf-writer.sh $startApache ;; stop) # No need for doing anything ;; *) echo "Usage: $0 [start|stop]" ;; esac