NSLU2-Linux
view · edit · print · history

Disclaimer

Well, the usual I take no responsibility for any data that you might loose due to following the guide, etc., etc., etc. My advice would be that you start by reading the guide all the way through and then decide if you are able to do what it says. The guide has only been tested on

  • ds101g+

The default setup

By default when you have the "Web Station" enabled you will get access to a special folder called "web" in which you can put your html/php files. This will allow you to run a single website from the DiskStation, accessed by pointing your web browser to the IP or hostname of your DiskStation.

The modified setup

The setup described below will allow you to host multiple websites from your DiskStation based on the hostname that the user types into the web browser. In Apache (the web server installed on the DiskStation) terms this is referred to as Name-based Virtual Hosts. E.g. entering www.myprivatewebsite.com into a web browser points to one website stored on your DiskStation and www.mypublicwebsite.com would point to a different website also stored on your DiskStation.

Requirements

You need to have the "Web Station" enabled on your DiskStation, you must be able to access your DiskStation website from the Internet (e.g. using port forwarding on your router), you need to have shell access to the DiskStation (telnet/ssh access) and you need to have at least 2 DNS resolvable hostnames associated with your IP address.

DynDNS

The easiest way to achieve the last requirement is to use a service such as DynDNS, which will allow you to register multiple free hostnames for your IP address (you just need to register as a user also free). If you need more professional hostnames you will have to buy (well, lease) a normal domain name through a domain registrar.

Hosting mutiple web sites from your DiskStation

For the sake of this example I shall assume that you have registered the hostnames "private.mine.nu" and "public.mine.nu" and have them associated with your IP address.

Notice that the ".mine.nu" is a standard DynDNS hostname suffix.

This example will setup the DiskStation such that when a user types "private.mine.nu" into a web browser it will display the default web site on your DiskStation, stored in the "web" folder. And when the user types in "public.mine.nu" it will display the contents of a folder called "mypublicsite".

  1. Create a new folder called "mypublicsite" using the standard administrative web interface (port 5000) running on your DiskStation.
  2. Put a simple html or php file in the new folder allowing you to tell the difference between the new folder and the standard web folder.
  3. Access your DiskStation shell using either telnet or ssh.
  4. Open up "/usr/syno/apache/conf/httpd.conf-user" using the VI editor (i.e. vi /usr/syno/apache/conf/httpd.conf-user).
  5. Locate section 3 in this file (indicated with the line "### Section 3: Virtual Hosts" in the file).
  6. Insert a line with NameVirtualHost * in the beginning of section 3. This will allow you to use virtual hosts.
  7. Insert a virtual host section for the default web site ("private.mine.nu"). This one should come before any other virtual host sections:
    <VirtualHost *>
    ServerName private.mine.nu
    DocumentRoot /volume1/web
    </VirtualHost>
  8. Insert another virtual host section for the "public.mine.nu" website.
    <VirtualHost *>
    ServerName public.mine.nu
    DocumentRoot /volume1/mypublicsite
    </VirtualHost>
  9. Save the httpd.conf-user file and exit VI.
  10. Open up "/usr/syno/etc/php.ini" and ensure that the setting open_basedir contains /volume1/mypublicsite
  11. Restart the webserver by typing /usr/syno/etc/rc.d/S97apache-user.sh restart
  12. Test that everything works as it should and if not make sure that you did everything above correctly.

Notice that the reason that your are editing the httpd.conf-user configuration file and not the standard httpd.conf file is that the DiskStation will generate the httpd.conf file everytime the webserver is started/restarted.

view · edit · print · history · Last edited by Peder Madsen.
Originally by Morten Nielsen.
Page last modified on August 27, 2006, at 02:47 PM