LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-16-2009, 11:50 AM   #1
NeillH
LQ Newbie
 
Registered: Aug 2009
Location: England-Bedfordshire
Posts: 17

Rep: Reputation: 0
Simple stuff - how does domain get routed to my application directory


This is really basic, but driving me mad, I was hoping to route around and understand how this works.

How does a Domain get pointed to an application directory.

My DNS is set to point my domain to my ip address, however how does the url getd to the application directory on my server.

I have no idea how this works and I can find any information on this, I have tried searching within my Matrix panel to see if I can find any way of doing this but no luck.

It must be really basic, so please be blunt if i am being a numbty.

NeillH
 
Old 10-16-2009, 02:13 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Hi NeillH,

I'll first try to understand your question.

The DNS (domain name service) only manages the relation between the IP-adress and the name of a Computer.

Otherwise if you open an URL in a browser you are connected with a file (mostly any *.htm) in a directory on the computer.

Is that your question? who tells the browser where inside a computer is the file I want to open (very simply spoken)?

Well an URL has two parts, the first one is an alias which is (more or less) related to the IP-adress of the server, the rest is the directory on the computer. In fact there is not one computer for every website and there is not necessarily only one website hosted on one server.

You can try that out, replace the "http://.....org" part of an URL with the related IP-adress (which you can get if ping the site).

Markus
 
Old 10-17-2009, 09:38 AM   #3
NeillH
LQ Newbie
 
Registered: Aug 2009
Location: England-Bedfordshire
Posts: 17

Original Poster
Rep: Reputation: 0
Hi Markus

You have understood my poorly worded question.

I can reach my web site by using my IP of my unix server and directory (77.xx.xx.xx/mydirectory). I will have more than one web site on this server so how do I reach this directory by domain name. There must be a configuration I am missing by pointing the domain to the correct ditectory, as there may be more than one application directory.

When I ping the site I get following

pining mywebsite.co.uk [77.xx.xx.xx] with 32 bytes of data then I get 4 time outs. So it does appear that the domain is resolving to my IP address, but I guess then it has no where to go when it hits my server.

I am getting less confued now, but not quite there yet.

Neillh
 
Old 10-17-2009, 09:59 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Your webserver (e.g. apache) is listening on port 80. When a html header is received, the webserver checks the html header (for the requested domain) and decides which pages (DocumentRoot) to serve. This is called 'name-based' and multiple domains can be on the same ip-address.

This does not work with https (webserver listening on port 443) as the request is encrypted and to decrypt it, it must know the key. To know the key, it must know the domain. So we have a chicken and egg problem. The solution is that each domain has it's own ip-address so apache can decide based on ip-address which pages to serve. Exception is subdomains with a wildcard certificate.

Last edited by Wim Sturkenboom; 10-17-2009 at 10:04 AM.
 
Old 10-18-2009, 03:11 AM   #5
NeillH
LQ Newbie
 
Registered: Aug 2009
Location: England-Bedfordshire
Posts: 17

Original Poster
Rep: Reputation: 0
OK so if I have multiple web sites on my server I will need a different IP address for each site?
 
Old 10-18-2009, 03:21 AM   #6
NeillH
LQ Newbie
 
Registered: Aug 2009
Location: England-Bedfordshire
Posts: 17

Original Poster
Rep: Reputation: 0
Having re read response I am not using an HTTPS adress so it looks like I dont need IP unique addresses per site. So the "name based" approach should be used. How can this be configure?
 
Old 10-18-2009, 05:03 AM   #7
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by NeillH View Post
Having re read response I am not using an HTTPS adress so it looks like I dont need IP unique addresses per site. So the "name based" approach should be used. How can this be configure?
By reading the documentation?

Google: Apache Configuration
 
Old 10-18-2009, 05:58 AM   #8
NeillH
LQ Newbie
 
Registered: Aug 2009
Location: England-Bedfordshire
Posts: 17

Original Poster
Rep: Reputation: 0
So I stopped being lazy and found some references to this, and all is working now but just need to clarify a few things.

I found reference to vitualhost setting in httpd.conf, so I checked my server and found no entries here in my httpd.conf.

However I did find a file called vhost.conf and this seems to be how the domain gets resolved to my application directory. Although not clear it seems that if I add a directory called the domain name then this will get resolved.


<VirtualHost 77.xx.xx.xx:80>
ServerName myservername.com
ServerAlias www.myserverdomain.com
ServerAdmin webmaster@myserverdomain.com
DocumentRoot /home/default/myserverdomain.com/user/htdocs
ErrorLog /home/default/myserverdomain.com/user/logfiles/error_log
TransferLog /home/default/myserverdomain.com/user/logfiles/access_log
php_admin_value open_basedir /tmp:/home/default/myserverdomain.com
SuexecUserGroup myuser matrixdomain
ScriptAlias /cgi-bin/ /home/default/myserverdomain.com/user/htdocs/cgi-bin/
AddHandler server-parsed .shtml
AddType text/html .shtml
<Location />
Options +Includes
</Location>
# Begin user directives <--
# --> End user directives
</VirtualHost>

<VirtualHost 77.xx.xx.xx:80>
ServerName echoecho.eu
ServerAlias www.echoecho.eu
"vhost.conf" 268L, 10059C

So is it that simple?, just create a directory, called mynewwebsite.com, in the root shown in vhost.conf, place my web application files in this new dir. Then all works OK when I point my domain to my server IP address?

Neillh - a lot less confussed.
 
Old 10-18-2009, 06:52 AM   #9
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Yep, it's basically that simple. Below my virtual host configuration as reference; note that I don't use server aliases and don't specify ip-addresses in the VirtualHost directive.
Code:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

# catch-all
<VirtualHost *:80>
    ServerAdmin me@mydomain
    DocumentRoot /srv/httpd/htdocs
    ServerName btd-techweb02
</VirtualHost>

# site 1
<VirtualHost *:80>
    ServerAdmin me@mydomain
    DocumentRoot /home/wim/www/site1/web
    ServerName site1.btd-techweb02
    ErrorLog /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log common

#WimS
# this is required to prevent message 403 "Forbidden"
    <Directory "/home/wim/www/site1/web">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

# site2
<VirtualHost *:80>
    ServerAdmin me@mydomain
    DocumentRoot /home/wim/www/site2/web
    ServerName site2.btd-techweb02
    ErrorLog /var/log/httpd/error_log
    CustomLog /var/log/httpd/access_log common

#WimS
# this is required to prevent message 403 "Forbidden"
    <Directory "/home/wim/www/site2/web">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't Compile Most Simple Qt Application binarybob0001 Programming 1 11-17-2007 02:49 AM
Want to Create a Simple X Application binarybob0001 Programming 6 11-15-2007 12:49 PM
Need some help w/ unpacking a tar.gz & directory stuff davidbix Linux - Newbie 2 10-21-2005 08:01 PM
VB simple stuff... ashirazi Programming 3 10-20-2004 01:50 PM
Just an example of what a pain simple stuff in linux can be Edward78 Linux - General 17 05-03-2003 04:59 AM


All times are GMT -5. The time now is 12:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration