NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
devbobo
Nov 29, 2009Aspirant
HOW TO: Hosting multiple websites
G'day Guys,
For some time I've wanted to host multiple websites from a single ReadyNAS unit...I haven't had the time to investigate it.
1. Backup all the .conf files in /etc/frontview/apache
2. Backup all the .conf files in /etc/frontview/apache - so you can restore the originals if you screw something up !!!
3. Edit /etc/frontview/apache/Virtual.conf
Original file
Modified file
4. Create a new my-virtual.conf file in /etc/frontview/apache/addons, this way it will be auto loaded without modifying any other files. The example below has definitions for two websites....add/remove as required.
my-virtual.conf
5. shutdown apache, killall apache-ssl
6. restart apache, apache-ssl -f /etc/frontview/apache/httpd.conf
7. All done :D
CAVEATS
1. Toggling the state of HTTP within Frontview rewrites Virtual.conf so the above changes will be lost.
ReadyNAS Team
1. It would be nice if the above changes could be made to the format of /etc/frontview/apache/Virtual.conf, so that changes aren't overwritten
2. I currently have to add the Location element to undo a global definition within httpd.conf. It would be awesome if this was removed from httpd.conf and added to Virtual.conf as...
Cheers,
David
For some time I've wanted to host multiple websites from a single ReadyNAS unit...I haven't had the time to investigate it.
1. Backup all the .conf files in /etc/frontview/apache
2. Backup all the .conf files in /etc/frontview/apache - so you can restore the originals if you screw something up !!!
3. Edit /etc/frontview/apache/Virtual.conf
Original file
<VirtualHost _default_:80>
SSLEngine off
RewriteEngine on
RewriteRule ^/admin/(.*)$ https://%{SERVER_NAME}/admin/$1 [R,L]
</VirtualHost>
Modified file
NameVirtualHost *:80
<VirtualHost *:80>
SSLEngine off
RewriteEngine on
RewriteRule ^/admin/(.*)$ https://%{SERVER_NAME}/admin/$1 [R,L]
</VirtualHost>
4. Create a new my-virtual.conf file in /etc/frontview/apache/addons, this way it will be auto loaded without modifying any other files. The example below has definitions for two websites....add/remove as required.
my-virtual.conf
<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /path/to/example.com
<Directory /path/to/example.com>
Options Indexes
Order allow,deny
Allow from all
</Directory>
<Location /index.html>
SetHandler none
Order Allow,Deny
Allow from all
</Location>
SSLEngine off
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain.net
DocumentRoot /path/to/domain.net
<Directory /path/to/domain.net>
Options Indexes
Order allow,deny
Allow from all
</Directory>
<Location /index.html>
SetHandler none
Order Allow,Deny
Allow from all
</Location>
SSLEngine off
</VirtualHost>
5. shutdown apache, killall apache-ssl
6. restart apache, apache-ssl -f /etc/frontview/apache/httpd.conf
7. All done :D
CAVEATS
1. Toggling the state of HTTP within Frontview rewrites Virtual.conf so the above changes will be lost.
ReadyNAS Team
1. It would be nice if the above changes could be made to the format of /etc/frontview/apache/Virtual.conf, so that changes aren't overwritten
2. I currently have to add the Location element to undo a global definition within httpd.conf. It would be awesome if this was removed from httpd.conf and added to Virtual.conf as...
NameVirtualHost *:80
<VirtualHost *:80>
<Location /index.html>
SetHandler server-status
Order Deny,Allow
Deny from all
</Location>
SSLEngine off
RewriteEngine on
RewriteRule ^/admin/(.*)$ https://%{SERVER_NAME}/admin/$1 [R,L]
</VirtualHost>
Cheers,
David
129 Replies
Replies have been turned off for this discussion
- super_poussinVirtuosowhy not using /etc/frontview/apache/addons/ for this ?
- devboboAspirant
super-poussin wrote: why not using /etc/frontview/apache/addons/ for this ?
Step 4 uses that location, however, the way /etc/frontview/apache/Virtual.conf has been defined....it really doesn't allow expansion, hence the reason for modifying it. You can't have mixed declarations of <VirtualHost _default_:80> and <VirtualHost *:80> as the first one declared will always be used. - dbott67GuideNice how-to... thanks for sharing.
Does this still require these steps?
http://www.readynas.com/?p=135
Currently, I've got my blog-thingy hosted on the ReadyNAS Pro. In Frontview, under the HTTP protocol I am redirecting HTTP traffic to the read-only HTTP share "webserver". How does your how-to fit in with this?
Notice that when you try to go to my site http://home.bott.ca/ in automatically redirects to the webserver share (as I expect it would - http://home.bott.ca/webserver/).
Do all websites have to be placed within this "webserver" share?
I guess I'm just a bit confused as to how this works. If you've got any sites hosted on your NAS where you can provide an example, I'd love to see it in action.
Regards,
Dave - devboboAspirantI don't use that option, I currently have it set to 'None Selected'. Using that options adds an additional rewrite rule to /etc/frontview/apache/Virtual.conf, something like this...
RewriteRule ^/$ /webserver [R,L]
Instead, I have a single share called 'Sites' with a folder for each site that I have configured, then the my-virtual.conf sets the DocumentRoot to the specific Site folder. But I have only done this to make my life easy for updating content. Each site could exist on totally different shares, there is no restriction on that.
I'm not hosting anything elaborate, just some firefox extensions and other stuff that I hack around with, here's two sites that are currently hosted off my NAS...
http://www.smugglr.net
http://smugbrowser.introversion.com.au/beta - WhoCares_Mentor
dbott67 wrote: Nice how-to... thanks for sharing.
Does this still require these steps?
http://www.readynas.com/?p=135
No, actually the approach from this Howto is more flexible but requires more work and a lot more knowledge about how things "really work".dbott67 wrote: Currently, I've got my blog-thingy hosted on the ReadyNAS Pro. In Frontview, under the HTTP protocol I am redirecting HTTP traffic to the read-only HTTP share "webserver". How does your how-to fit in with this?
Two totally different beasts.
The way you do it will create a config similar to this:<VirtualHost _default_:80>
SSLEngine off
RewriteEngine on
RewriteRule ^/$ /website [R,L]
RewriteRule ^/admin/(.*)$ https://%{SERVER_NAME}/admin/$1 [R,L]
</VirtualHost>
The important part is line 4 where all requests are redirected to the Share "website". That's what you already noticed here:dbott67 wrote: Notice that when you try to go to my site http://home.bott.ca/ in automatically redirects to the webserver share (as I expect it would - http://home.bott.ca/webserver/).
While this works, it will just allow you to host one website on your NAS.
Comes in the Howto. The important part here is that you can have not only one but several <VirtualHost ...> entries.
This leads straight to your next question:dbott67 wrote: Do all websites have to be placed within this "webserver" share?
No. Let's have a look at the VirtualHost definition:<VirtualHost *:80>
ServerName www.example.com
DocumentRoot /path/to/example.com
<Directory /path/to/example.com>
Options Indexes
Order allow,deny
Allow from all
</Directory>
<Location /index.html>
SetHandler none
Order Allow,Deny
Allow from all
</Location>
SSLEngine off
</VirtualHost>
Notice line 3. The DocumentRoot ... tells Apache where to look for the files it should serve to the user. In this case this would be /path/to/example.com
Also important is line 2. The ServerName ... tells Apache what site this configuration is meant for.
A simple, yet very abbreviated example:<VirtualHost *:80>
ServerName server1.dyndns.org
DocumentRoot /website1
(...)
</VirtualHost>
<VirtualHost *:80>
ServerName anotherserver.dyndns.org
DocumentRoot /website2
(...)
</VirtualHost>
Now what happens when a request comes in is this: Apache will look in the headers for the host name the user wanted to address. Say the user requested "anotherserver.dyndns,org". Apache finds the defintion for that server, looks into the directory /website2 and will serve the file index.html if it's to be found there. (That's an overly simplistic explanation but you should get the drift). /website2 doesn't have to be a share, it just has to exist.
Likewise, since all Apache cares about is the host name, not the IP address, "server1.dyndns.org" and "anotherserver.dyndns.org" may of course point to the same (your public) IP address.
I really hope this was somewhat understandable since I tried to cramp many things in a "not too long to digest" post ;)
-Stefan - devboboAspirant
WhoCares? wrote:
No, actually the approach from this Howto is more flexible but requires more work and a lot more knowledge about how things "really work".
Thanks for the explanation for those who don't understand how apache works :D - mdgm-ntgrNETGEAR Employee RetiredNice how-to. Will need to take a look sometime.
- WhoCares_Mentor
devbobo wrote: Thanks for the explanation for those who don't understand how apache works :D
No problem ;)
The only real problem I see with this is that it opens a huge barn door for people to break FrontView in the process of setting up their websites. And since I'm quite confident that the majority of ReadyNAS users doesn't know how to fix Apache configs, I'll leave the support calls to you :-D
-Stefan - devboboAspirant
WhoCares? wrote: devbobo wrote: Thanks for the explanation for those who don't understand how apache works :D
No problem ;)
The only real problem I see with this is that it opens a huge barn door for people to break FrontView in the process of setting up their websites. And since I'm quite confident that the majority of ReadyNAS users doesn't know how to fix Apache configs, I'll leave the support calls to you :-D
-Stefan
That was my primary concern, and that's why I decided to post in this forum. If above changes were made to the Virtual.conf file by the ReadyNAS team....the risk of that happening would be reduced considerably and that would open up the prospect of making this into an Add-on which would remove the risk all together. - mdgm-ntgrNETGEAR Employee Retired
devbobo wrote: That was my primary concern, and that's why I decided to post in this forum. If above changes were made to the Virtual.conf file by the ReadyNAS team....the risk of that happening would be reduced considerably and that would open up the prospect of making this into an Add-on which would remove the risk all together.
You may wish to create a new post in the feature request forum: viewforum.php?f=18
You could state the change you want and point to this thread for the reason why.
Related Content
NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!