Forum Moderators: phranque

Message Too Old, No Replies

XP2 Kills localhost apache hacks?!?

         

Brett_Tabke

1:17 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I've used this hack for years to do local developement. By changing the hosts file in windows to point a domain at a local ip, you can then fake the browser and system into calling the domain up from your local disk/localhost.

Apache:


<VirtualHost 127.0.0.5>
DocumentRoot /temp
ServerName www.temp.com
ServerAdmin webmaster@temp.com
ScriptAlias /cgi-bin/ /temp/cgi-bin/
TransferLog logs/tempaccess.log
ScriptLog logs/tempscripterror.log
</VirtualHost>

Windows hosts file entry:

127.0.0.5 www.temp.com

The dns cache knows that temp is on 127.0.0.5:


ipconfig /displaydns

www.temp.com
----------------------------------------
Record Name . . . . . : www.temp.com
Record Type . . . . . : 1
Time To Live . . . . : 568929
Data Length . . . . . : 4
Section . . . . . . . : Answer
A (Host) Record . . . : 127.0.0.5

I installed XP2, and note this hack no longer works!?
It is like apache never gets the request now and it never shows up in the apache log file as a request. The server does respond on 127.0.0.1 but not on 127.0.0.5?

How do i get apache to listen on those new ips for localhost?

any tips?

ukgimp

1:40 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[webmasterworld.com...]

Does using names work?

Brett_Tabke

2:00 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Good test. Yes name based does work. However, that is all on 127.0.0.1. That won't work with my older http 1 scripts. (so I need to get things working on the other local host ips).

I guess the question, is how do I get apache under XP/SP2 to listen on 127.0.0.*?

bakedjake

6:31 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Is Windows firewall for your ethernet interface turned off?

Brett_Tabke

7:58 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Ya, I wouldn't be able to get to localhost at all if it weren't.

bakedjake

8:03 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What happens when you ping the .5 address? Does it respond?

What happens when you telnet to port 80?

Brett_Tabke

8:33 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Yes. The browser "acts" like it is doing something - like trying to resolve it out on the net. Apache never gets the request though. It just won't respond to it.

Double confirmed that this is only a service pack 2 issue as all my other xp sp1's work great.

jdMorgan

8:56 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this Apache 2.0, or earlier?

I'm wondering what your setup is with respect to the Listen, Port, and BindAddress directives. Apache Binding [httpd.apache.org]

It's possible that security-related XP services are tying up all unbound addresses and ports by default, and that turning off the windows firewall doesn't really remove those bindings (I've never played with this configuration myself, though, just a guess).

Jim

bakedjake

8:57 pm on Jan 21, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



What happens when you telnet to port 80?

Brett_Tabke

1:56 am on Jan 23, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



>Is this Apache 2.0, or earlier?

Pick a card - any card. (both installed on machine and both do the same jd)

Is not the virtualhost ip address the same a Listen command?

<VirtualHost 127.0.0.5>
DocumentRoot /temp
ServerName www.temp.com
</VirtualHost>

Other than that, the only other thing in the conf file that I think is important is that the servername is set to local host:

ServerName localhost

Jake, the server is there on any port I want to set it on, it is the IP address that is the issue.

bakedjake

2:50 am on Jan 23, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Dumb question, but did you add the IP address to your config in your windows TCP/IP network settings.

kalos

8:14 am on Jan 23, 2005 (gmt 0)

10+ Year Member



127.0.0.1 blah.com

worked fine on my XP Pro SP2 box redirecting a valid domain to my local machine (as a matter of fact, I may set example.com to 127.0.0.1 just to mess with my roomie now). Unless 127.0.0.5 is bound to your NIC then it won't matter what you set in your HOSTS file for that IP address as it will try to find an address off your local machine, and network.

[edited by: Brett_Tabke at 12:39 pm (utc) on Jan. 23, 2005]
[edit reason] examplefied [/edit]

Xoc

11:02 am on Jan 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is a Microsoft Knowledge Base article on this. Have you upgraded to all the windows update patches? The article can be found here: Programs that connect to IP addresses that are in the loopback address range may not work as you expect in Windows XP Service Pack 2 [support.microsoft.com]

Brett_Tabke

12:25 pm on Jan 23, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Xoc you rock!

That did the trick!

Thanks!