Virtual Host

Published on January 2017 | Categories: Documents | Downloads: 42 | Comments: 0 | Views: 273
of 7
Download PDF   Embed   Report

Comments

Content

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 different hosts can share the same IP address. Name-based virtual hosting is usually simpler, since you need only configure your DNS server to map each hostname to the correct IP address and then configure the Apache HTTP Server to recognize the different hostnames. Name-based virtual hosting also eases the demand for scarce IP addresses. Therefore you should use name-based virtual hosting unless there is a specific reason to choose IP-based virtual hosting. Some reasons why you might consider using IP-based virtual hosting: 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 * <VirtualHost *> ServerName www.domain.tld DocumentRoot /www/domain </VirtualHost> <VirtualHost *> ServerName www.otherdomain.tld DocumentRoot /www/otherdomain </VirtualHost>

You can alternatively specify an explicit IP address in place of the * in both the NameVirtualHost and <VirtualHost> directives. The IP address is required in version 1.3.12 and earlier. Many servers want to be accessible by more than one name. This is possible with the ServerAlias directive, placed inside the <VirtualHost> section. For example if you add this to the first <VirtualHost> block above
ServerAlias domain.tld *.domain.tld

Of course, you can't just make up names and place them in ServerName or ServerAlias. You must first have your DNS server properly configured to map those names to an IP address associated with your server.

Introduction: Sometimes we need to configure a virtual host setting for our server. This is required in case when we have 2 servers, where one is main server and other is standby server. If the main server goes down then standby server can take over the control and user does not have to change the URL. That means we can have same host name but different IPs (or different physical machines). Other situation is when we want to host multiple web sites on a single host. In this case IP address remains same (means physical server is only one) where as we can have multiple hostname configured for the same. The first example (same hostname and different IP address) is called IP based virtual host and the second example (same IP address but multiple hostname is called name based virtual host). So we have 2 types of virtual hosts 1. IP based (Same hostname – multiple IPs. Used in backup or standby situation). 2. Name based (Same IP address or physical server – multiple hostname. Used for hosting multiple web sites) Configuring Virtual Hosts: We will see here how to configure name based virtual host. That means we will be able to refer to our server with 2 URLs or 2 hostnames. Configuration of virtual hosts needs simple change in httpd.conf file. We can do it using Enterprise Manager or through backend by directly editing http.conf file. We will see both the options here. *** The below virtual host configuration is for middle tier 1) Configuration using Enterprise Manager Before starting the virtual host configuration, we need the hostname recognized by server. For this we need to make entry in our /etc/hosts file as shown below. 144.25.76.171 advait.us.oracle.com advait

Here 144.25.76.171 is the actual IP address of the host, followed by advait.us.oracle.com, which is the hostname and domain name and finally the hostname. These changes needs to be made as root user. Step 1) Create a new port

You can create a new port on which you HTTP server can listen. Actually these steps can be skipped and you can use existing port for new virtual host. But just to avoid confusion we will create a new port for virtual host. You can add “Listen 9988″ (ignore double quotes) to your http.conf file of middle tier and bounce the http server for middle tier. Here port number I have selected is 9988, but you can select any port that is free. From Enterprise manager you can go to Mid Tier home page -> HTTP_Server component -> Administration tab -> Server Properties. Here you can see “Listening Addresses and Ports” section. You can just add a row and put the new port number as shown in below figure.

Scroll down to the bottom and click on Apply button. It will ask to restart HTTP server. Click on yes. In case if you are doing manual changes, do remember to bounce the HTTP server using OPMN. Step 2) Got to Virtual Host section using Mid Tier Home -> HTTP Server component -> Virtual Host tab. Click on “Create” button. It will take you to next screen. Here you have to enter “DocumentRoot”. Enter some different path (Other than htdocs). This way we can keep the content of virtual host with our main server. This is useful in hosting 2 different website on same server.

Step 3) Next it will ask you to enter the name of new virtual host that you want to create. You enter the name that you entered in /etc/hosts file above. Below fig shows the same.

Also it will ask for which IP address to listen to. You can just enable it for all IP address. Else you can provide specific IP address and it will listen for that IP address and port number only. Step 4) In this step it will ask for the port number to listen to. If you remember in step 1) we created a port number to be used for virtual host. You can select the same port from option 2 as show below.

Step 5) This is the last step in virtual host creation, where it will ask for log file location and log level. It will be better if you give some identified name for log file so that you will come to know later. Else better to create a new directory inside logs directory for virtual hosts log files.

Finally it will show the summary of the inputs and you can submit the same. This will add entry in http.conf file and then bounce HTTP server so that changes takes effect.

This will put the entry in httpd.conf file as given below. Listen 9988 NameVirtualHost advait.us.oracle.com:9988 <VirtualHost advait.us.oracle.com:9988> ServerAdmin [email protected] ServerName advait.us.oracle.com DocumentRoot /dy/oracle/product/AS10g/mid/Apache/Apache/advait ErrorLog “|/dy/oracle/product/AS10g/mid/Apache/Apache/bin/rotatelogs /dy/oracle /product/AS10g/mid/Apache/Apache/logs/error_log_advait 43200″ common </VirtualHost> Listen 9988 was added when you created a new port for virtual host setup. After bouncing the virtual setting will take effect and you will be able to access the URL http://(Virtual_host_name):(port for virtual host)/ In my case the URL becomes http://advait.oracle.com:9988/

This will display index.html if present in you Document Root for virtual host. 2) Manual configuration In case of manual configuration we just put the Virtual host configuration directive in httpd.conf file of mid tier Apache and bounce the apache.

This how

to create a new virtual host -OAS

To create a new HTTP Virtual Host in Oracle Application Server: Adding a new port number for the HTTP VH to listen to: 1. login to the Oracle Enterprise Manager (i.e. domain.name.com: 1810) 2. select the application server instance (under Standalone Instances) 3. under Ports tab, look for Oracle HTTP Server listening to ports 7777-7877 (these are defaults and may also include 80) and click the configure icon 4. under Listening Addresses and Ports click button „Add another row‟ 5. in the new row, add the ip-address of the server and the new port number you want the virtual host to listen to and Apply the settings Adding the new HTTP Virtual Host: 1. 2. 3. 4. under the application server, select HTTP_Server click the Virtual Hosts tab select an existing HTTPs or create a new one click Create Like if selected an existing Server Name: can be the same Document Root: /the/full/path/to/the/dir/you/want/to/host Directory Index: index.php (or whatever the index page is) Listen on a specific IP address: app.server.ip.address Listen to specific port: select the newly created port from list Protocol: http (if no need for secure) Logging: remove unless needed 5. click Create to create the new virtual host Notes: -During the creation of the virtual host you must choose to use ip-address entry -If your physical path to a dir was i.e. : /home/oracle/mydir/otherdir then running: domain.name.com: port -will point to that destination

enable virtual host setup. The step to add hostname entry in /etc/hosts holds true in manual configuration as well.

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close