Solved

Apache2 web server IP binding

Posted on 2010-09-02
4
618 Views
Last Modified: 2013-11-15
OK, this is sort of a noobish question here.  I have an Apache2 web server running on Ubuntu Karmic with two .php web sites on it.  One site is strictly for internal use and the other I want to be accessed from the Internet.  As most of us know in IIS you can tie a specific IP address to a specific web page.  How can I do this in Apache?  I have tried playing with VirtualHost, but I cannot seem to get that to work correctly.  For you Linux/Apache wizards this should be an easy 500 pts.
0
Comment
Question by:219com
4 Comments
 
LVL 16

Assisted Solution

by:gelonida
gelonida earned 250 total points
ID: 33591215
The directory to look at is
/etc/apache2/sites-available

thre yu create additiona entries
currently you have probably one entry named
default
and perhaps oen entry named
defaul_ssl

Let's assume you want to have an hhtp (not https) server
then copy default to (for example) external_server
and copy
default to internal_server


In the beginning of the file change the line named virtual host to something liek
<VirtualHost 192.168.0.10:80>
for your internal server

then adapt the rest of the config



in the other file change the Virtualhost entry to the external IP address

if you ant to test from home you could have one server on 127.0.0.1
and the other on your local network addres

restart apache

and try it out






0
 
LVL 3

Expert Comment

by:simoesp
ID: 33592198
NameVirtualHost aaa.aaa.aaa.aaa:80
NameVirtualHost bbb.bbb.bbb.bbb:80

<VirtualHost aaa.aaa.aaa.aaa:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>

<VirtualHost bbb.bbb.bbb.bbb:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>


hope it helps
0
 
LVL 15

Accepted Solution

by:
samri earned 250 total points
ID: 33595178
hi 219com,

This should be rather straightforward, but then, there are tons of possibilities that could contribute to the "not-working" situation :)

The recommendation given earlier should work -- but I havent got time to validate.

Here are the authoritative docs from Apache on the default apache installation.

http://httpd.apache.org/docs/2.2/vhosts/

On Ubuntu however (I do not have one, so, Google is the way:)

http://ubuntu-tutorials.com/2008/01/09/setting-up-name-based-virtual-hosting/
http://www.debuntu.org/2006/02/22/7-virtual-hosting-using-apache-2


In brief, OS and platform independent, all you need to do is,

1. Makesure the vhost modules is loaded,
2. Enable the Vhosting directive,
3. Create the Vhost container for each vhosts.

Following is a section from httpd.conf from Centos 5.4
### Section 3: Virtual Hosts
#
# VirtualHost: 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.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

Open in new window

0
 

Author Closing Comment

by:219com
ID: 33789486
Thx guys
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you use Debian 6 Squeeze and you are tired of looking at the childish graphical GDM login screen that is used by default, here's an easy way to change it. If you've already tried to change it you've probably discovered that none of the old met…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question