How to create third-level domain / subdomain on a QNAP ?

Post your questions about Web Server usage and Apache + PHP + MySQL/SQLite web applications.
Post Reply
Gdieterling
Starting out
Posts: 15
Joined: Sat Aug 02, 2008 2:23 pm

How to create third-level domain / subdomain on a QNAP ?

Post by Gdieterling »

Hey guys,

I have a QNAP TS-409 which is on a fixed internet IP.

I succesfully redirected the "80 port" to the Qweb application and can access it when typing my domain name.

However, I would like to create third-level domains. I searched the web and it seems possible to do it with "BIND" (a programme) or through the edit of a .conf file in Apache ...

As I'm a total noob with Linux, I was wondering wether any of you guys would have any experience on how to create a third-level domain (subdomain) on a QNAP or if you had any insights that might help me to do it !
I can create type A / CNAME / MX DNS entries with my registrar ... maybe it will help ! :wink:

Thanks in advance !
Model : TS-453 Pro
Firmware version : 4.1.1
OS : Windows 7
OS Language : French
# of HDDs : 3
HDD model / Capacity : WD Red / 4 To
RAID configuration : RAID 5
Services enabled : SABNZBD | SickRage-TV | CouchPotato2 | HD Station | TwonkyMedia Server
NAS connection speed / MTU : 1,500
User avatar
fribse
Experience counts
Posts: 2090
Joined: Mon Feb 11, 2008 2:50 am
Location: Greve, Denmark
Contact:

Re: How to create third-level domain / subdomain on a QNAP ?

Post by fribse »

He, this is not complicated, but it does take a lot of steps.
First of you have to create an A record on your DNS server, so that the internet know about this host.
Then you have to enable virtual hosts in Apache.
You also have to decide where to store your new host.
You can find a lot of articles about virtual hosts on Apache on the forum, and on the internet.
Best regards
Fribse

NO, RAID is NOT backup - Use RAID-Certified 24x7 drives for raid
HOWTO's:
Make automatic backup of ALL MySQL databases http://forum.qnap.com/viewtopic.php?f=32&t=15628

NAS-659 Pro II (3 GB Ram), Raid1, Survailance station, local backup destination + NAS-853A (16 GB Ram), Virtualization Station, Plex, iDrive
Network: Fritz!Box 7560 + 24p SG200 + 2x8p SG200 + 8p POE EdgeCore + 300/300 mbit Internet
Gdieterling
Starting out
Posts: 15
Joined: Sat Aug 02, 2008 2:23 pm

Re: How to create third-level domain / subdomain on a QNAP ?

Post by Gdieterling »

Hi Frisbe

Thanks for your answer (again ;))

I'm gonna look it up !
I was wondering wether Apache was installed on the QNAP, I guess it is !

When you say that I have to decide where to store the new host, I'm not sure to understand ...
Which host are you talking about ?
Model : TS-453 Pro
Firmware version : 4.1.1
OS : Windows 7
OS Language : French
# of HDDs : 3
HDD model / Capacity : WD Red / 4 To
RAID configuration : RAID 5
Services enabled : SABNZBD | SickRage-TV | CouchPotato2 | HD Station | TwonkyMedia Server
NAS connection speed / MTU : 1,500
User avatar
fribse
Experience counts
Posts: 2090
Joined: Mon Feb 11, 2008 2:50 am
Location: Greve, Denmark
Contact:

Re: How to create third-level domain / subdomain on a QNAP ?

Post by fribse »

Well, each domain/subdomain can be a new host.

I'll give you an example close to my own home ;-)

I have http://www.site1.dk
I also have webmail.site1.dk

Each has it's own DNS A entry, due to difference in platforms, they also reside on different IP's, and hosts.

I also have http://www.site2.dk
That's pointing to the same IP as http://www.site1.dk

In fact, the virtual host in Apache is built like this:

Code: Select all

<VirtualHost *:80>
	ServerName http://www.site1.dk
	ServerAlias site1.dk http://www.site1.com site1.com http://www.site2.dk site2.dk
	DocumentRoot "/share/Qweb/site1"
	<Directory "/share/Qweb/site1">
		Options FollowSymLinks MultiViews
		Order allow,deny
		Allow from all
	</Directory>
...
</VirtualHost>
This let's the apache serve the same website to several hostnames.

I also have a site 3

Code: Select all

<VirtualHost *:80>
	ServerName http://www.site3.dk
	ServerAlias site3.dk
	DocumentRoot "/share/Qweb/site3"
	<Directory "/share/Qweb/site3">
		Options FollowSymLinks MultiViews
		Order allow,deny
		Allow from all
	</Directory>
...
</VirtualHost>
I can of course also create a subsite.site3.dk

Code: Select all

<VirtualHost *:80>
	ServerName subsite.site3.dk
	DocumentRoot "/share/Qweb/subsitesite3"
	<Directory "/share/Qweb/subsitesite3">
		Options FollowSymLinks MultiViews
		Order allow,deny
		Allow from all
	</Directory>
...
</VirtualHost>
As I don't want to put this statements into the original apache config (located in /etc/config/apache/apache.conf), I've created my own under Qweb called customized.conf, and I've putten my own statements into that, I've only added a 'include /share/Qweb/customized.conf' to the bottom the the apache configuration.

I'm also not using Qweb as root dir for my webserver, because I have several sites served from the QNAP, and I don't want to have a ton of shares for different webservers, so I've placed the root dirs in folders on the Qweb share.

When you're at it, put these in the top of your new conf file:

Code: Select all

ServerName www.site1.dk
DocumentRoot "/share/Qweb/site1"
<Directory />
		Order Deny,Allow
    Deny from all
</Directory>

This will set the servername to your primary site, and then it will harden the webserver a bit, by prohibiting everything (you then make allowances in each virtualhost).

I hope this helps a bit, there are a million ways to do this.
Best regards
Fribse

NO, RAID is NOT backup - Use RAID-Certified 24x7 drives for raid
HOWTO's:
Make automatic backup of ALL MySQL databases http://forum.qnap.com/viewtopic.php?f=32&t=15628

NAS-659 Pro II (3 GB Ram), Raid1, Survailance station, local backup destination + NAS-853A (16 GB Ram), Virtualization Station, Plex, iDrive
Network: Fritz!Box 7560 + 24p SG200 + 2x8p SG200 + 8p POE EdgeCore + 300/300 mbit Internet
Gdieterling
Starting out
Posts: 15
Joined: Sat Aug 02, 2008 2:23 pm

Re: How to create third-level domain / subdomain on a QNAP ?

Post by Gdieterling »

THank you, it does help me to understand !

I'm gonna try that this WE :)

Thanks again frisbe, you are of great help !
Model : TS-453 Pro
Firmware version : 4.1.1
OS : Windows 7
OS Language : French
# of HDDs : 3
HDD model / Capacity : WD Red / 4 To
RAID configuration : RAID 5
Services enabled : SABNZBD | SickRage-TV | CouchPotato2 | HD Station | TwonkyMedia Server
NAS connection speed / MTU : 1,500
User avatar
thorejoha
Know my way around
Posts: 144
Joined: Mon Mar 24, 2008 9:41 pm

Re: How to create third-level domain / subdomain on a QNAP ?

Post by thorejoha »

I had some problems with this virtual host
The solution for me was like this under here
First i added the the line

Code: Select all

include /share/Qweb/customized.conf
in the bottom of apache.conf

Then I created the file customized.conf in the share Qweb

In my old Site I dont need www, and then I dont use serveralias in this.
But if you want server alias, you can put this in.
I this file i added this lines

Code: Select all

NameVirtualHost *

<VirtualHost *>
ServerName mysite1.dyndns.info
DocumentRoot "/share/Qweb"
</VirtualHost>

<VirtualHost *>
ServerName mysite2.homelinux.com
ServerAlias www.mysite2.homelinux.com
DocumentRoot "/share/Qweb/linux/mysite2"
</VirtualHost>


<VirtualHost *>
ServerName mysite3.homelinux.com
ServerAlias www.mysite3.homelinux.com
DocumentRoot "/share/Qweb/linux/mysite3"
</VirtualHost>


<VirtualHost *>
ServerName mysite4.homelinux.com
ServerAlias www.mysite4.homelinux.com
DocumentRoot "/share/Qweb/linux/mysite4"
</VirtualHost>

Then i restarted the apache server with this command

Code: Select all

/etc/init.d/./Qthttpd.sh restart

This works fine for me, and now I have my old site in the root directory , and the tree new sites in the directory: share/Qweb/linux
My Tutorials:
Tutorial:How to config webserver on Qnas!
Tutorial:How to use loginscript and Robocopy
Tutorial:How to set up DynDNS on Qnas!
Tutorial:How to move large files on Qnas!
Tutorial:How to edit apache.conf on Qnas!
Tutorial:How to seed files and folders in Qget
Tutorial:How to fix slow wordpress on Qnas!

See also Don`s How To guide!
And Frisbe`s signatur for more Tips and Tricks!
_______________________________________
NAS nr 1: TS-109 Pro FW: 3.1.0 Build 0708T - 1 x Seagate 500Gb + 1X USB 500GB Qraid
NAS nr 2: TS-109 Pro II FW: 3.1.0 Build 0708T - 1 x Western Digital 1Tb
____________________________________________________________________________
Post Reply

Return to “Web Server & Applications (Apache + PHP + MySQL / SQLite)”