Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Apache2 web server IP binding

Posted on 2010-09-02
4
Medium Priority
?
642 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 17

Assisted Solution

by:gelonida
gelonida earned 1000 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

972 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