Community discussions

MikroTik App
 
gimmepatiencequickly
newbie
Topic Author
Posts: 35
Joined: Wed Jan 30, 2008 1:00 pm
Location: South Africa

2 Web domains, one server, How do I route?

Wed Feb 04, 2009 1:01 pm

Hello guys and gals.

Once again I have a small problem, this time it is
Accessing my webserver.

The domains:
http://www.wowcomputers.co.za --- DNS Resolution --- 41.208.61.58
http://www.jonathan.za.net ---- DNS Resolution --- 41.208.61.58

My Network:
41.208.61.58 ---- ISP Static public IP Connected to Cisco Router
192.168.1.1 ---- Internal Cisco router IP connectectd to network port
192.168.1.5 --- Mikrotik Router (Eth1) connected to Cisco router
10.254.0.254 --- Mikrotik Router (Eth2)
10.254.0.110 --- Windows XP pro Web server with Apache 2.2
10.254.0.101 --- My office PC where I manage the network and servers from.

NAT Config:
# feb/04/2009 11:03:19 by RouterOS 2.9.50
# software id = XXXX-XXX
#
/ ip firewall nat 
add chain=srcnat action=masquerade comment="" disabled=no 
add chain=dstnat action=dst-nat to-addresses=10.254.0.110 to-ports=80 in-interface=ether1 dst-address=192.168.1.5 dst-port=80 protocol=tcp comment="Server dst-nat WEB" disabled=no
add chain=dstnat action=dst-nat to-addresses=10.254.0.110 to-ports=80 in-interface=ether2 dst-address=192.168.1.5 dst-port=80 protocol=tcp comment="Server dst-nat WEB" disabled=no
So now....
When I type http://www.wowcomputers.co.za in a web browser it goes to the page I expect it to. and displays the information from the webserver.
I asked a friend (Connecting from outside my network) to do the same, and he gets the same web page. So we know the webserver is working

When I type in http://www.jonathan.za.net I get the same page as from http://www.wowcomputers.co.za. (NB. ALL BROWSING HISTORY HAS BEEN DELETED)
How do I get 2 different domains to point to the same server, and the display different pages too.

I am guessing I need to do something in apache configuration, by letting it listen for specific web address, but the APACHE logs say that both domains orginate from 10.254.0.254.

for more info about my webserver ( I KNOW HUGE SECURITY RISK, but if your really want to get in you will.) http://www.wowcomputers.co.za/phpinfo.php

Thanks
Defer not till tomorrow to be wise, tomorrow's sun to thee may never
rise.
--- William Congreve
 
galaxynet
Long time Member
Long time Member
Posts: 648
Joined: Fri Dec 17, 2004 2:52 pm
Contact:

Re: 2 Web domains, one server, How do I route?

Wed Feb 04, 2009 5:21 pm

gimmepatiencequickly -

Well you have a couple of things going on here....

Your first dst-nat rule is correct. The second rule (ether2 - I don't know what you're trying to do there....192.168.1.5 shouldn't be showing up on that interface.....)

Your src-nat rule.... Isn't the cisco nat'ing for you? Even if it isn't - why use masq - use the direct method - src-nat to-addr=192.168.1.5. Actually - you should have a different 192.168.1.x address for your web sever - so as not to get in the way of accessing the MT router itself....but that's just me.

Lastly - as to your Apache Web 'appliance' on the windows server...I have not used Apache on Windows for quite sometime but I am familiar with it. Under your Apache setup there are 'two' portions to the config - enabled-sites and available-sites, make sure both http://www.sites are in both configs (enabled and available). That should fix your issue.... If not go over to the Apache home page and look up configuring under windows - there should be plenty of FAQs there....

R/

Thom
Thom Lawless
General Manager
RapidWiFi, LLC
thom.lawless [at] rapidwifi.com
 
gimmepatiencequickly
newbie
Topic Author
Posts: 35
Joined: Wed Jan 30, 2008 1:00 pm
Location: South Africa

Re: 2 Web domains, one server, How do I route?

Thu Feb 05, 2009 7:13 am

Hello Galaxynet, thanks for the response...
gimmepatiencequickly -

Well you have a couple of things going on here....

Your first dst-nat rule is correct. The second rule (ether2 - I don't know what you're trying to do there....192.168.1.5 shouldn't be showing up on that interface.....)
If I do not add the ETHER2 rule, I will not be able to access the webserver from my office PC Due to the DNS resolving to 192.168.1.5, from the internal network.
Your src-nat rule.... Isn't the cisco nat'ing for you? Even if it isn't - why use masq - use the direct method - src-nat to-addr=192.168.1.5. Actually - you should have a different 192.168.1.x address for your web sever - so as not to get in the way of accessing the MT router itself....but that's just me.
The problem I have with the CISCO router is that I do not have access to it. It is owned and administered by my ISP, they will not allow me to have the login details. I have my whole network, behind my MT router, allowing me to configure my router as I wish.
Lastly - as to your Apache Web 'appliance' on the windows server...I have not used Apache on Windows for quite sometime but I am familiar with it. Under your Apache setup there are 'two' portions to the config - enabled-sites and available-sites, make sure both http://www.sites are in both configs (enabled and available). That should fix your issue.... If not go over to the Apache home page and look up configuring under windows - there should be plenty of FAQs there....
Thanks.. checked out what you were talking about, did not find anything, but I will do more research... seems to be a "Virtualhost" thing. The thing is that the webserver sees all traffic coming from 10.254.0.254, which is my MT router, so I do not know how it will determine correct traffic.


Thanks for the help so far
Defer not till tomorrow to be wise, tomorrow's sun to thee may never
rise.
--- William Congreve
 
SurferTim
Forum Guru
Forum Guru
Posts: 4637
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: 2 Web domains, one server, How do I route?

Thu Feb 05, 2009 12:54 pm

Greetings!

I use Apache for virtual hosting on my servers for multiple websites. The ips are the same, the difference is in the header. But, like galaxynet, I have no experience with Apache on Windows, but I imagine it could not be much different. Does it have an "httpd.conf" file? If so this is it:. Look at the end of the file to see where the html docs are. I will use mine from Linux (/var/www/html), so translate where necessary.

Create folders
/var/www/html/domain1
/var/www/html/domain2

Unremark these:
#NameVirtualHost *:80
#Setenv VLOG

Add these at the end of the file. The first domain:
<VirtualHost *:80>
    ServerAdmin myemail@mydomain.com
    DocumentRoot /var/www/html/domain1
    ServerName mydomain.com
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin myemail@mydomain.com
    DocumentRoot /var/www/html/domain1
    ServerName www.mydomain.com
</VirtualHost>
Then second domain:
<VirtualHost *:80>
    ServerAdmin myemail@mydomain.com
    DocumentRoot /var/www/html/domain2
    ServerName yourdomain.com
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin myemail@mydomain.com
    DocumentRoot /var/www/html/domain2
    ServerName www.yourdomain.com
</VirtualHost>
Put docs in the respective folders. Won't do SSL to these domains tho. Not a way I have seen anyway. SSL encrypts the header also, so there is really no way to access the domain there. Once again, you will probably need to change the DocumentRoot to a Windows type directory.
Hope that helps.

Nothing needs to be done on the MT routers. I have three domains coming through mine right now.

OOPS! ....and restart Apache for changes to take effect!
 
gimmepatiencequickly
newbie
Topic Author
Posts: 35
Joined: Wed Jan 30, 2008 1:00 pm
Location: South Africa

Re: 2 Web domains, one server, How do I route?

Fri Feb 06, 2009 9:15 am

Thank you Guys,

I have just finished reading the Apache documentation... and I am going to do exactly what you said. (Well almost anyway)

Thank you to both of you for your help.... Much appreciated
Defer not till tomorrow to be wise, tomorrow's sun to thee may never
rise.
--- William Congreve

Who is online

Users browsing this forum: No registered users and 104 guests