Question

I'm wondering if anyone can help me define a new local VirtualHost using Apache.

The goal is to have a site that is viewable only from the local network (hidden behind a firewall). Right now I have Webmin installed and it runs on transaction:10000. I am trying to get the other site running on transaction:7000.

The following does not work:

DocumentRoot /var/path

Is there a better way to do this? I'm new to Apache and trying to figure this out.

Summary: Need local /var/path directory to run on a port other than 80 for local access only.

Was it helpful?

Solution

I'm assuming that you don't know to Apache Virtual Host Code. I will show you how to use it. If this didn't help you please don't hesitate to reply to me.
You must place code in your HTTPD.CONF which can be found in the conf folder. If your file is called wwwroot instead just change the name in the code below BUT DO NOT CHANGE THE NAME OF THE FOLDER!!!

NameVirtualHost 111.22.33.44
<VirtualHost *:7000>
ServerName www.domain.tld
ServerPath /domain
DocumentRoot /htdocs/domain
</VirtualHost>

What does this mean? It means that a request for any URI beginning with "/domain" will be served from the virtual host www.domain.tld. This means that the pages can be accessed as domain.tld/domain/ for all clients, although clients sending a Host: header can also access it as domain.tld/.

In order to make this work, put a link on your primary virtual host's page to http://www.domain.tld/domain/. Then, in the virtual host's pages, be sure to use either purely relative links (e.g., "file.html" or "../icons/image.gif") or links containing the prefacing /domain/ (e.g., "http://www.domain.tld/domain/misc/file.html" or "/domain/misc/file.html").

So all domains will be pointed to your IP address and based on the domain name if it is "www.domain.tld" it will take you to the folder "/htdocs/domain" or "/wwwroot/domain"

EDIT:

<Directory "/var/path/">
 Order Deny,Allow
 Deny from all
 Allow from 127.0.0.1
</Directory>

This lets access to the "/var/path/" folder from only localhost which is where Apache is configured which is on your computer!

Good Luck!!!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top