Solved

Apache2 web server IP binding

Posted on 2010-09-02
4
625 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 17

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

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…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

734 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