Solved

Problems using host file to redirect websites to local host for testing (setting test site to my ip)

Posted on 2010-09-08
23
1,424 Views
Last Modified: 2013-12-14
Just inherited a large classic asp site.  Customer wants to retain absolute urls back to same site (cites Google advantage, which I doubt), so I want to be able to test by redirecting the site to my local server using the host file.  After MANY roadblocks, I now get a "403 forbidden" error.  This is after fighting lots of localstart.asp problems.  I guess there's something important I don't know about authentication.  Has anyone ever done this using a vmware xp virtual machine hosted by Windows 7?  Other ideas?  
0
Comment
Question by:Don Smith
  • 11
  • 11
23 Comments
 
LVL 6

Expert Comment

by:Kailash Aghera
ID: 33633392
It seems that you have not set default page in web server. Can you access web site using http://website.com/pagename.asp ?
0
 
LVL 1

Author Comment

by:Don Smith
ID: 33633565
There is a default page and it is in the defaults documents list.  This site does start up fine from Dreamweaver, but of course jumps out to www-land on the absolute url's.  Yes to your question.
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33639677
H,
IE interpretes the hostfile on loading. Wat do you have in your C:\windows\system32\drivers\etc\hosts file?
When you ping www.site.com does it respond and resolve your local VM?
Did you setup the host header on the VM to respond to www.site.com?
Did you ALSO setup the VM HOST FILE to respond to itself on the same IP?
-Hades666
0
 
LVL 1

Author Comment

by:Don Smith
ID: 33640152
Here is my host file on the virtual xp machine:

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# 127.0.0.1       localhost
127.0.0.1      www.restaker.com
127.0.0.1      restaker.com

Are you suggesting I need to change the windows 7 host machine's host file also?  Windows 7 doesn't allow me to change the hosts file without changing a lot of permissions, which I'd rather avoid if not necessary.

restaker.com is the website, which is real, which I want to test on my local machine.
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33640991
on windows7 , START | Right click on NOTEPAD and chose RUN AS ADMINISTRATOR.
Then browse to C:\windows\system32\drivers\etc\hosts  and modify the file with
127.0.0.1      www.restaker.com
127.0.0.1      restaker.com

Your windows7 will now refresh it properly.
-Hades666
0
 
LVL 1

Author Comment

by:Don Smith
ID: 33641312
I made that change, but still getting the IE error "HTTP 403 Forbidden".  Also, Firefox comes back with "Directory Listing Denied", even though I use no trailing "/".

To review:  The issue is on my virtual (vmware) xp machine running under Windows 7.  Dreamweaver 8 can launch the site ok with IE and Firefox, but when I try to go raw to www.restaker.com I still get the above errors.

I'm thinking this HAS to be an authentication issue.  The site takes anonymous access, and windows Authentication is checked.  I run on my own user account, which has admin privileges.

Any other suggestion?  (thanks for your responses so far, btw)
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33641455
Hi,
I understand the issue. You have a XP_VM Running on your Windows7 Host. When you browse through dreamweaver it loads. Ok, Were is dreamweaver installed? on Windows 7?
When you ping www.restaker.com from windows7, what IP does it resolve?
-Hades666
0
 
LVL 1

Author Comment

by:Don Smith
ID: 33642221
Dreamweaver 8 is on the virtual box (xp).  Not on Windows 7.

Ping to www.restaker.com from Windows 7 WITHOUT hosts entries: 208.68.104.123, and surfing to it works, too.

Ping to www.restaker.com from Windows 7 WITH hosts entries: 127.0.0.1, and surfing to it brings me to a "Welcome to IIS7" page, presumably because I have no default website set up for Windows 7.

Same ping results on the virtual xp machine, by the way.
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33642722
Hi,
That is the issue there.
Your entry needs to point to the XPVM IP. "127.0.0.1" is a reserved INTERNAL IP. So if you add www.restaker.com 127.0.0.1 to your local Host File, it will always look for IIS Services on that host.  This is why 127.0.0.1 loads Welcome to IIS7 with the entry on windows7. This shows that you have IIS installed in a default configuration.
So, Open your XPVM, Click Start, RUN Type CMD, then type "ipconfig". This is your XPVM IP Address. It should be something like 192.168.*.* etc...
Then, as mentioned above, open  Notepad as Administrator and add the www.restaker.com xp.vm.ipaddress.
 
Hades666
 
0
 
LVL 1

Author Comment

by:Don Smith
ID: 33643166
I did what you suggested (on both the host and the virtual box), and I still get the response I mentioned above:

>>I made that change, but still getting the IE error "HTTP 403 Forbidden".  
>>Also, Firefox comes back with "Directory Listing Denied", even though I use no trailing "/".

Also, restarted both IE and Firefox.  And stopped and started IIS on the virtual machine.

Just so I understand, are you saying that when redirecting locally on the virtual machine, the Windows 7 machine's IIS is involved?  I wouldn't have thought so, but your suggestion implied that.  In any event, I did both, but no change.
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33643184
Run ipconfig on the XP vm and provide the output please. There is something you are missing or i am not explaining properly.
Cheers,
Hades666
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Author Comment

by:Don Smith
ID: 33643209
Here you are:

C:\Documents and Settings\dsmith>ipconfig

Windows IP Configuration


Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . : Belkin
        IP Address. . . . . . . . . . . . : 192.168.2.4
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 192.168.2.1

C:\Documents and Settings\dsmith>

By the way, I should have maybe mentioned this:  I wondered about noise between the machines earlier, so I had my client, who has a pure XP machine to try the same redirect (had to walk him through the hosts change), and he got a similar result to mine.
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33643225
From the HOST Windows7, you can ping 192.168.2.4 right?
Is the the IP you add to www.restaker.com in the windows7 host file? If not, It should be.
-Hades666
0
 
LVL 1

Author Comment

by:Don Smith
ID: 33643238
Yes, and yes.  Still fuzzy on why the windows 7 host file is involved - my ignorance.
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33643254
Because you are browsing IIS on the XPVM. For windows7 to resolve the XPVM IIS, you need to bind it in the hostfile.
OK, so your Win7 host has www.restaker.com 192.168.2.4.
Does it load from IE on Win7?
On XPVM, ping www.restaker.com and paste the output here.
Cheers,
Hades666
0
 
LVL 1

Author Comment

by:Don Smith
ID: 33643297
1. In case this is unclear, both the local website and dreamweaver are on the XPVM.  The need to redirect to the local site is also on the XPVM.  From an application perspective, Windows 7 is not involved.

2. Yes, both hosts have 192.168.2.4 www.restaker.com.  You don't mean to say in your first question that the hosts entry should have the site name first, then the local IP address, do you?

3. I get the same responses from IE and Firefox on both the W7 host machine and the XPVM.  Before I fooled with the Win7 machine's hosts file, IE and Firefox (on the Win7 machine) both went normally to the real (remote) site.

Here's the XPVM ping:

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\dsmith>ping www.restaker.com

Pinging www.restaker.com [192.168.2.4] with 32 bytes of data:
Reply from 192.168.2.4: bytes=32 time<1ms TTL=128
Reply from 192.168.2.4: bytes=32 time=1ms TTL=128
Reply from 192.168.2.4: bytes=32 time=1ms TTL=128
Reply from 192.168.2.4: bytes=32 time<1ms TTL=128

Ping statistics for 192.168.2.4:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 1ms, Average = 0ms

C:\Users\dsmith>

Hope this helps.
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33643314
1. Yes, to use the local you need to modify your host file on ALL machines.
2. Typo... you are correct. 192.168.2.4 www.restaker.com
3. This is good, so you are seeing the same issue not and NOT resolving your production site.
SO, on the XPVM what does http://localhost resolve? What IIS host headers did you add to the site under IIS Manager?
What URL does dreamweaver load? Does it load with the HOST ENTRIES in place?
My guess is no ;)
-Hades666
0
 
LVL 1

Author Comment

by:Don Smith
ID: 33643358
On XPVM http://localhost returns "Directory Listing Denied".  I don't see an ip address flash by.

"X-Powered-By: ASP.NET" is the only entry in Custom HTTP Headers.  I didn't add that.  

Dreamweaver loads "http:\\virtualxp\restaker\Index.asp

Don't understand "Does it load with the HOST ENTRIES in place?"
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33643382
Dreamweaver is loading http:\\virtualxp\restaker\Index.asp where restaker is a virtualpath to the main site. Going by what you provided virtualXP is the name of the machine.
If that is the case, then these should load.
http:\\localhost\restaker\Index.asp
http:\\www.restaker.com\restaker\Index.asp
 
The reason for directory listing denied is beacuse a default document is not enabled in the virtual path and directory listing is denied.
Now when i say the host entries in place, i mean 192.168.5.4 www.restaker.com is added to the hosts files.
Thse should load fine.
Hades666
 
0
 
LVL 1

Author Comment

by:Don Smith
ID: 33643440
Not bad, hades, not bad.  They work fine.  Do I infer from this that to redirect via texts, the target site (at least its default page) needs to be actually IN the default website (i.e. Inetpub\wwwroot) and not in a (sub) virtual directory?  This can make sense to me.
0
 
LVL 30

Accepted Solution

by:
Brad Howe earned 500 total points
ID: 33643467
That is correct.
You would need ot move the entire directory from as example c:\inetpub\wwwroot\restaker up 1 level to c:\inetpub\wwwroot\.
Just remember, HOST entries are needed on every machine to bypass DNS resolution and you need to point it to the server/machine IP, not the loopback ip 127.0.0.1.
Sorry for all the comments, :) Glad it is working for you. If it isn't what you need, let me know and we can reconfigure it further.
-Hades666
0
 
LVL 1

Author Comment

by:Don Smith
ID: 33643487
Got it.  I work on several sites locally, so I use virtual directories a lot.  I guess this means that without a lot of workarounds, you can only fake-redirect one website.

I really appreciate the time you've spent working on this.  Will close this problem now with points, etc.  If there are more problems once I move the site, I'll start a new problem.

Again, thanks a lot.
0
 
LVL 30

Expert Comment

by:Brad Howe
ID: 33643515
Well, if you are using virtual directories, you can use hosts entries plus a custom default page like such.
<%

If InStr(lcase(Request.ServerVariables("SERVER_NAME")),"www.domain.com") > 0 Then
Response.AddHeader "Location","http://virtualxp/domain"

ElseIf InStr(lcase(Request.ServerVariables("SERVER_NAME")),"www.company.com") > 0 Then
Response.Redirect("http://virtualxp/company")

ElseIf InStr(lcase(Request.ServerVariables("SERVER_NAME")),"www.testsite.com") > 0 Then
Response.AddHeader "Location","http://virtualxp/testsite/"

Else

'load up whatever is displayed by the subdomain itself or redirect elsewhere

End If
%>
Cheers, Hades666
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Decrypting SSL traffic in wireshark 7 28
Log on FTP From Local Machine 6 22
svg file 10 32
RDP Sonicwall 8 25
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
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.
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now