Solved

multiple virtual hosts on apache: no domain, but subdomains for network access to IP address?

Posted on 2010-08-24
7
827 Views
Last Modified: 2013-11-30
Hello,

Initial Goal:
-http://192.168.1.48 will access test website 1
-http://test.192.168.1.48 will access test website 1 as well

Next Goal:
http://test.192.168.1.48 will access test website 2, set up like test website 1

My first attempts are below. I tried changing the *:80 bits to 192.168.1.48 (may or may not be wise). Website 1 still works fine. Typing in http://test.192.168.1.48 after apache restart brought up a not found error. :(

Any idea on how to get this to work for anyone on my network and also myself to start? I greatly appriciate your feedback in advance. :D

Best regards,

Chris
#/etc/apache2/ports.conf
NameVirtualHost 192.168.1.48
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

#/etc/apache2/sites-available/default
<VirtualHost 192.168.1.48>

	ServerAdmin webmaster@localhost

	DocumentRoot /mnt/hgfs/mywebsite
	<Directory />
		Options FollowSymLinks
		AllowOverride None
		Allow from all
	</Directory>
	<Directory /mnt/hgfs/mywebsite/>
		AllowOverride All
		Allow from all
	</Directory>

	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>

	ErrorLog /var/log/apache2/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128 
    </Directory>

</VirtualHost>

<VirtualHost 192.168.1.48>
ServerAdmin webmaster@localhost
ServerName 192.168.1.48
ServerAlias test.192.168.1.48
DocumentRoot /mnt/hgfs/mywebsite
</VirtualHost>

Open in new window

0
Comment
Question by:Ultrus
[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
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33512851
I've made Vhosts using IP addresses.  But to put 'test' in front of it requires a DNS or host lookup before it ever gets to the server.  I don't think that scheme is going to work for you.
0
 
LVL 10

Author Comment

by:Ultrus
ID: 33512914
Thanks for the feedback. Maybe I could use ports instead? However that might not work the best as my IT gurus are going to set up some remote access forwarding goodness and needed specific ports specified.

I'm trying to figure out a way to test websites without putting them in a sub-directory, since some of the websites use doc root relative links and it gets messy when we go live with the sites.

Any thoughts on how to make this work? Maybe an htaccess file that handles redirects somehow?

Thanks again.
0
 
LVL 3

Expert Comment

by:Ravi Goru
ID: 33513040

my sincere advise is to stop trying with ip based virtual hosting. try name based virtual hosting, and configure a dns or use a hosts file.. such as ..

xyz.com 192.168.1.48  
test.xyz.com 192.168.1.48
test1.xyz.com 192.168.1.48
test2.xyz.com 192.168.1.48

and everything should work ..or else comeback and lets try resolving the issues..

best of luck..
RaviGoru


0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 10

Author Comment

by:Ultrus
ID: 33513146
I'm reading up on DNS now. It appears I can edit a hosts file to get things going where they need to for a local network. I thought that was a client-side thing though. Would this work for users accessing the test server who don't have a custom hosts file on their machine, with a hosts file edited on the server? This question may seem silly after I read more. Feedback is welcome. I'll get back after some research.
0
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 300 total points
ID: 33514306
For test purposes, I setup web sites on my local server using IP based virtual hosts.  You can give the sites any IP in the current network segment.  If the machine IP is 192.168.1.48, I would use something like 192.168.1.100, 192.168.1.101, and 192.168.1.102.  IPs high enough to get them out of the DHCP range.  I have two Linux servers setup that way.

Yes, hosts file is client side.  You can put a lookup page in the main server wwwroot that lists all the web sites on the server.
0
 
LVL 8

Assisted Solution

by:allen-davis
allen-davis earned 200 total points
ID: 33601949
DaveBaldwin is on the right track in the comment above:
I believe you might be blending the idea of name base and IP based hosting.  You can't really mix a name and an IP address together because one is DNS (or name resolution of some kind) and the other is the actual IP address of the site.  You would would likely want to use specific IP addresses for the testing you're trying to do.  If you use the IP addresses, it might be a little harder to remember which site is where but you do not have to register anything with DNS or create any host entries.
What kind of environment are you in and what do you have available to you?  Can you make requests to a corporate DNS team for requests such as this?  If so, managing IP based virtual hosts would not be hard but you would need to request a HOST (A record) from the DNS team for each name to map it to an IP. Also, do the applications care about the host name of the site?
One alternative to a hosts file would be just to have an HTML file with a list of links to the IP addresses.  something like a web page that says test one links to http://1.1.1.2 and test2 links to http://1.1.1.3, etc and have all test users just start with that page as an index of testing sites available.  This is not as desirable having DNS setup correctly but it seems like an accetable workaround to what you're facing that avoids keeping many hosts files in sync with any changes you make to your sites.
0
 
LVL 10

Author Closing Comment

by:Ultrus
ID: 33603082
Thanks for the great feedback. I'm far less foggy now on how to make this work. For new IP addresses, my options are limited and restricted. However that's another topic and I don't want to drag this one out. Have an excellent weekend!
0

Featured Post

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

623 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