[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1454
  • Last Modified:

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

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
Don Smith
Asked:
Don Smith
  • 11
  • 11
1 Solution
 
Kailash AgheraCommented:
It seems that you have not set default page in web server. Can you access web site using http://website.com/pagename.asp ?
0
 
Don SmithAuthor Commented:
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
 
Brad HoweCommented:
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
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
Don SmithAuthor Commented:
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
 
Brad HoweCommented:
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
 
Don SmithAuthor Commented:
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
 
Brad HoweCommented:
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
 
Don SmithAuthor Commented:
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
 
Brad HoweCommented:
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
 
Don SmithAuthor Commented:
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
 
Brad HoweCommented:
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
 
Don SmithAuthor Commented:
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
 
Brad HoweCommented:
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
 
Don SmithAuthor Commented:
Yes, and yes.  Still fuzzy on why the windows 7 host file is involved - my ignorance.
0
 
Brad HoweCommented:
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
 
Don SmithAuthor Commented:
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
 
Brad HoweCommented:
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
 
Don SmithAuthor Commented:
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
 
Brad HoweCommented:
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
 
Don SmithAuthor Commented:
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
 
Brad HoweCommented:
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
 
Don SmithAuthor Commented:
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
 
Brad HoweCommented:
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 11
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now