Solved

Apache2 web server IP binding

Posted on 2010-09-02
4
608 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now