how to serve multiple Domains from one Computer in a local network

Solution 1:

Finally, I found the solution. You must setup a DNS server in your local network, if you have any Server Edition OS computer it will be easy to config its DNS server and point it to your project's IP. but when there is no Server Computer in the network (eg: home networks) the problem will be finding a DNS server to curry the responsibility.

I will config Apache on Windows 7 or anything else to handling Django projects with WSGI...

my local IP is 192.168.2.2 and I Bind it with my MAC-ADDRESS in the Router Settings.
NOTICE: be sure to make your IP to be unchangeable, otherwise it will make your DNS Server and local Network unstable.

Config Apache to serve multiple Domains:

the first step is to config Apache to run the projects:
below will serve myProject1 on www.myproject1.local and myProject2 on www.myproject2.local

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName www.myProject1.local
    ServerAlias myProject1.local *.myProject1.local 
    ServerAdmin [email protected]
    DocumentRoot "C:/path/to/myProject1/"
</VirtualHost>

<VirtualHost *:80>
    ServerName www.myProject2.local
    ServerAlias myProject2.local *.myProject2.local 
    ServerAdmin [email protected]
    DocumentRoot "C:/another/path/to/myProject2/"
</VirtualHost>

...

for more information visit : [Apache Name-based Virtual Host Support]

  1. Launch Django Projects with WSGI:

if you want to serve a PHP project its works, but to config WSGI you have to make a little changes like below. I treat project1 to be django project

<VirtualHost *:80>
    ServerName www.myProject1.local
    ServerAlias myProject1.local *.myProject1.local 
    ServerAdmin [email protected]
    #WSGIDaemonProcess myProject1 processes=2 threads=15 display-name=%{GROUP}
    #WSGIProcessGroup  myProject1
    WSGIScriptAlias / "C:/path/to/myProject1/myproject1.wsgi"
</VirtualHost>

...

Be sure to load : [mod_wsgi.so]

commented lines WSGIDaemonProcess and WSGIProcessGroup are options to perform better WSGI service for more informations visit : [mod_wsgi Wiki Pages]

  1. Installing a DNS Server

now you must config your dns server. in my case I have no dns server installed on my computer so first step is to find proper dns server to do the job.
I Use [MaraDNS], and config it like below:

mararc file

ipv4_bind_addresses             = "192.168.2.2"
timestamp_type                  = 2
random_seed_file                = "secret.txt"
hide_disclaimer                 = "YES"
csv2                            = {}
csv2["myproject1.local."]       = "db.default.txt"
csv2["myproject2.local."]       = "db.default.txt"
upstream_servers                = {}
upstream_servers["."]           = "yyy.yyy.yyy.yyy, zzz.zzz.zzz.zzz"

and the db.default.txt file like below

%           192.168.2.2 ~
www.%       192.168.2.2 ~

for more information about maraDNS visit MaraDNS Website

  1. Launching DNS Server:

Launch maraDNS Server by

maradns -f mararc
  1. Router Settings :

you could access your domains by setting primary DNS server to point to 192.168.2.2 for each computer in your local network. but you also could set the Router DHCP server to use your IP as the default DNS Server. it just need access to the Router web-Administration.
so enter your IP there as DNS Server and the job is done.

  1. Enjoy the Trick:

now you can to serve your projects in local network as faked domains without using :port-number or IP addresses. just enter myproject1.local in address-bar of any of your local network computer or WiFi devices and get the right result.
:)