How-To Wiele stron w serwerze Web

Silas Mariusz

Silas Mariusz

rm -rf /
Help us, GOD!
Apr 5, 2008
9,804
25
2,194
153
38
www.devspark.pl
QNAP
TS-x77
Ethernet
1 GbE
Creating multiple websites on your NAS.
There are already running several apache servers on your NAS. These have different special purposes. To have your NAS serve multiple domains, there is no need to add additional apache servers, you can serve them all from one Apache server.
All the magic lies inside apache, by using VirtualHosts.
First of, you need to create a folderstructure on the NAS, that the apache can utilize.
We already have Qweb, so let's just extend the use of it, by moving all our websites to subfolders.
Qweb:
index.html
HTML files
Folders for the site

Changes to:
Qweb:
site1
HTML files
Folders for the site

site2
HTML files
Folders for the site.

Site3
....

To minimize the damage if the apache.conf file is reset by a firmware you should create your own config file. As we no longer want to use the root of Qweb to hold webserver pages, we can place the additional configuration there.

Qweb:\customization.conf

And then in the config file of the apache server ( /etc/config/apache/apache.conf), we can add
include /share/Qweb/customization.conf
at the bottom of apache.conf
An example of a config file could look like this:

ServerAdmin webmaster@site1.com
ServerName http://www.site1.com
DocumentRoot "/share/Qweb/site1”
<Directory />
Order Deny,Allow
Deny from all
</Directory>
<Directory "/share/Qweb/site1">
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ServerSignature Off
ServerTokens Prod

NameVirtualHost *:80

<VirtualHost *:80>
ServerName http://www.site1.com
ServerAlias site1.com http://www.site1.org site1.org
DocumentRoot "/share/Qweb/site1"
<Directory "/share/Qweb/site1">
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog /share/Qweb/logs/site1_error
CustomLog /share/Qweb/logs/site1_access combined
</VirtualHost>

First of we define where to send mail for users that experience errors, we also set a deny for root, which is lacking in the standard config.
Furthermore we limit the info we want to give away, and then we tell apache, that we want to create virtualhosts based on their name on port 80, which is the standard webport.

Finally we define a virtual server based on it's name.
There is the servername, which is what apache is to react on, and then there are aliases created for other sites, or TopLevelDomains, that you want to direct to the same site.
Finally there is a seperate logfile for each website, if you don't want to look at the logfiles, the errorlog and customlog lines can be omitted. Then the apache will use it's standard log file for every transaction.

To create another site, we simply add a new <VirtualHost> ... </VirtualHost> set, that points to another directory.

This way you can have some domains point to the same site, and others to seperate sites.

If you wish to harden the apache a bit more, you should find the Rewrite module, which can be found on the qnap forums, and then add the following lines to the customization config. The apache replies to some very unusual request methods, and there is no need for that, so we just want to redirect them to nothing.

LoadModule rewrite_module libexec/mod_rewrite.so
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE [OR]
RewriteCond %{REQUEST_METHOD} ^PROPFIND [OR]
RewriteCond %{REQUEST_METHOD} ^PROPPATCH [OR]
RewriteCond %{REQUEST_METHOD} ^MKCOL [OR]
RewriteCond %{REQUEST_METHOD} ^COPY [OR]
RewriteCond %{REQUEST_METHOD} ^MOVE [OR]
RewriteCond %{REQUEST_METHOD} ^LOCK [OR]
RewriteCond %{REQUEST_METHOD} ^UNLOCK [OR]
RewriteCond %{REQUEST_METHOD} ^LINK [OR]
RewriteCond %{REQUEST_METHOD} ^UNLINK
RewriteRule .* - [F]

ma ktos ochote tlumaczyc?
 
BitGSM

BitGSM

Passing Basics
Beginner
Feb 24, 2009
12
1
3
49
QNAP
TS-409/409 Pro
Ethernet
null
You must log in or register to view this reply.
 
jaroslawk

jaroslawk

Staff
Contributor
Oct 1, 2008
289
24
18
Konin
QNAP
TS-509 Pro
Ethernet
1 GbE
You must log in or register to view this reply.
 
BitGSM

BitGSM

Passing Basics
Beginner
Feb 24, 2009
12
1
3
49
QNAP
TS-409/409 Pro
Ethernet
null
You must log in or register to view this reply.
 
Gregor

Gregor

Systems Admin...
Q's Expert
Nov 28, 2008
212
1
13
18
QNAP
TS-239 Pro II
Ethernet
1 GbE
You must log in or register to view this reply.