• No results found

Virtual Host Continue

N/A
N/A
Protected

Academic year: 2021

Share "Virtual Host Continue"

Copied!
17
0
0

Loading.... (view fulltext now)

Full text

(1)

Virtual Hosting

The term virtual Host refers to the practice of running more than one web site (such as company1.example.com and

(2)

Virtual Host Continue

There are two types of Virtual Hosting:

a)

Name-base Virtual Host (More than one

web site per IP-Address)

b)

IP-base Virtual Host (An IP Address for

(3)

Virtual Host Continue

 If you want to maintain multiple

domains/hostnames on your machine you can setup VirtualHost containers for them. Most configurations use only name-based virtual hosts so the server doesn't need to worry about IP addresses. This is indicated by the asterisks in the directives below.

(4)

Virtual Host Continue

 Ensure that Apache listen to you given port (ex:80)

Listen 80

#Listen for virtual host requests on all IP addresses NameVirtualHost *:80

<VirtualHost *:80>

DocumentRoot /www/example ServerName www.example.com

#Other directive here </VirtualHost>

(5)

Virtual Host Continue

Ensue that Apache listen to you given port

(ex:8020)

Listen 8020

#Listen for virtual host requests on all IP

addresses

NameVirtualHost *:8020

<VirtualHost *:8020>

DocumentRoot /www/example

ServerName

www.example.com

#Other directive here

</VirtualHost>

(6)

Virtual Host Continue

Let’s have your Apache server listen to only port 80

Listen 80

# Listen for virtual host requests on all IP addresses NameVirtualHost *:80

<VirtualHost *:80>

DocumentRoot /www/example1 ServerName www.example.com # Other directives here

</VirtualHost>

================================================ <VirtualHost *:80>

DocumentRoot /www/example2 ServerName www.example.org # Other directives here

(7)

Virtual Host Continue

 The asterisks match all addresses, so the main

server serves no requests. Due to the fact that www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first VirtualHost.

(8)

Virtual Host Continue

 You can, if you wish, replace * with the actual IP address of the system. In that case, the argument to VirtualHost

must match the argument to NameVirtualHost:  NameVirtualHost 172.20.30.40

<VirtualHost 172.20.30.40> # etc ...

Some other directive ...

(9)

Serving the same content on different IP addresses (such as an internal and external address).

 The server machine has two IP addresses (192.168.1.1 and 172.20.30.40). The machine is sitting between an internal (intranet) network and an external (internet) network. Outside of the network, the name

server.example.com resolves to the external address (172.20.30.40), but inside the network, that same name resolves to the internal address (192.168.1.1).

 The server can be made to respond to internal and external requests with the same content, with just one VirtualHost section.

(10)

Continues

Server configuration

NameVirtualHost 192.168.1.1 NameVirtualHost 172.20.30.40

<VirtualHost 192.168.1.1 172.20.30.40> DocumentRoot /www/server1

ServerName server.example.com ServerAlias server

</VirtualHost>

Now requests from both networks will be served from the same VirtualHost.

Note:

On the internal network, one can just use the name server rather than the fully qualified host name server.example.com.

(11)

Running different sites on different ports.

 You have multiple domains going to the same IP and also want to serve

multiple ports. By defining the ports in the "NameVirtualHost" tag, you can allow this to work.

Server configuration

 Listen 80

Listen 8080 NameVirtualHost 172.20.30.40:80 NameVirtualHost 172.20.30.40:8080 <VirtualHost 172.20.30.40:80> ServerName www.example.com DocumentRoot /www/domain-80 </VirtualHost> <VirtualHost 172.20.30.40:8080> ServerName www.example.com DocumentRoot /www/domain-8080 </VirtualHost>

(12)

Continues

<VirtualHost 172.20.30.40:80> ServerName www.example.org

DocumentRoot /www/otherdomain-80 </VirtualHost>

<VirtualHost 172.20.30.40:8080> ServerName www.example.org

DocumentRoot /www/otherdomain-8080 </VirtualHost>

(13)

IP-based virtual hosting

Server configuration  Listen 80

<VirtualHost 172.20.30.40>

DocumentRoot /www/example1 ServerName www.example.com </VirtualHost>

<VirtualHost 172.20.30.50>

DocumentRoot /www/example2 ServerName www.example.org </VirtualHost>

Requests for any address not specified in one of the

<VirtualHost> directives (such as localhost, for example) will go to the main server, if there is one.

(14)

Name-based vs. IP-based Virtual Hosts

 IP-based virtual hosts use the IP address of the

connection to determine the correct virtual host to serve. Therefore you need to have a separate IP address for each host. With name-based virtual hosting, the server relies on the client to report the hostname as part of the HTTP headers. Using this technique, many

(15)

Continues

Related Directives

•DocumentRoot

•NameVirtualHost

•ServerAlias

•ServerName

•ServerPath

(16)

Continues

 To use name-based virtual hosting, you must

designate the IP address (and possibly port) on the server that will be accepting requests for the hosts. This is configured using the

NameVirtualHost directive. In the normal case

where any and all IP addresses on the server should be used, you can use * as the argument

(17)

Continues

 For example, suppose that you are serving the domain www.domain.tld

and you wish to add the virtual host www.otherdomain.tld, which points at the same IP address. Then you simply add the following to httpd.conf:

 NameVirtualHost *:80

<VirtualHost *:80>

ServerName www.domain.tld

ServerAlias domain.tld *.domain.tld DocumentRoot /www/domain

</VirtualHost> <VirtualHost *:80>

ServerName www.otherdomain.tld DocumentRoot /www/otherdomain </VirtualHost>

References

Related documents

This is a good way to send customers documents and reminders and provides you with an audit trail since each email sent through the system is recorded in the notes for that

At the Open Government Partnership Summit in London on October 2013, the Global Open Data for Agriculture and Nutrition (GODAN)[13] was launched to support global efforts to

7 Using myDAQ in LabVIEW If you want to use the myDAQ inside LabVIEW for Data Acquisition, you either use the traditional NI-DAQmx features or you may use NI-ELVISmx features..

CTL had shown to be able to develop the English speaking skills of the students by learning in context, promoting their engagement and motivation in the learning

In number theory, many types of primes exist; one of such is the Sophie Germain prime. See [2-4] for some theories and recent developments onsome conjectures

At the same time, the idea cited above from the University of North Carolina’s Writing Centre is not borne out, even for this period; indeed, this was shown in a previous

By first analysing the image data in terms of the local image structures, such as lines or edges, and then controlling the filtering based on local information from the analysis

We have proposed a delay-tolerant adjustable code matrix optimization (DT-ACMO) scheme and algorithms for cooperative MIMO systems with a feedback channel using an ML receiver at