Apache proxy to IIS7

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Apache proxy to IIS7

Postby Tyree » 13. August 2010 00:29

I'm attempting to set up Apache (xampp) as proxy to IIS.

Here's the scenario:
I have some sites that I want Apache to serve and others that I want IIS to handle. I want Apache to be the front for IIS. If a user requests http://www.apachesite.com, I want it to hit the virtual host for that site and serve it up. However, if a user requests http://www.iissite.com, I want it to hit Apache's virtul host entry for that site which has a proxy line in it to send it over to the IIS server for processing.
I followed a guide on how to do this (I am a novice when it comes to server setups. Just learning).
http://www.codecurry.com/2009/05/run-ii ... ether.html

So, I think I have my IIS only listening to requests on port 8080 and Apache is set to listen to port 80. I've confirmed this is working by typing in the IP of the pc and appending the port: 192.168.1.3:8080 resolves to the IIS default site, while 192.168.1.3 resolves to the only other site set up under Apache. So, it appears the ports are set correctly. Here's what my httpd.conf file looks like:
Code: Select all
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
ProxyRequests Off #keep proxy to OFF or your server will act as a forward proxy

NameVirtualHost *:80

#Add proxy redirect to IIS for iissite.com
<VirtualHost *:80>
   ServerName iissite.com
   ServerAlias *.iissite.com
   DefaultType text/html
   <Directory "C:\Inetpub\wwwroot\iissite.com">
      Options Indexes FollowSymLinks
      AllowOverride none
      Order allow,deny
      Allow from all
   </Directory>
# sends all requests made to port 80 to another port 8080
   ProxyPass / http://www.iissite.com:8080/
#makes proper changes to server-side redirection header
   ProxyPassReverse / http://www.iissite.com:8080/
</VirtualHost>

#Add apachesite.com as virtual host
<VirtualHost *:80>
    ServerName apachesite.com
   ServerAlias *.apachesite.com
    DocumentRoot "C:/xampp/htdocs/apachesite.com/"
</VirtualHost>


The apache site works perfectly. But when I request the iis site, I get a "Service Temporarily Unavailable" error from apache.

What am I missing?

Thanks,
Matt
Tyree
 
Posts: 27
Joined: 10. September 2009 03:02

Re: Apache proxy to IIS7

Postby JonB » 13. August 2010 04:40

you better ask codecurry, sounds dumb to me.

oh, LOL - you did - hehehe

I'm of the opinion that the vhost whatever in Apache is unnecessary. I 'think' IIS needs to listen on one port, and Apache on another - and never the twain shall meet. I don't think there's a way to redirect that request onto another port as the IIS response will likely go to port 8080. You are trying to circumvent an obvious design construct.

As I said - 'sounds dumb to me', but its your box and your time. :shock:

(note: there are routers that can do this in hardware [at least there used to be lol] with an assist from router programming and you would likely need a second IP address and/or NIC)

:mrgreen:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Apache proxy to IIS7

Postby Tyree » 13. August 2010 13:03

Well, if it is dumb, then there are a lot of dumb people. There are posts and guides all over the place for doing this exact same thing. I just can't get it to work. That's what the codecurry blog was all about. Doing this exact same thing. Apache is indeed capable of doing this.

Doesn't really matter much right now anyway. The computer I was using threw in the towel last night. Won't even get past the BIOS screen. Apparently it thought it was a dumb idea too. :?
Tyree
 
Posts: 27
Joined: 10. September 2009 03:02

Re: Apache proxy to IIS7

Postby JonB » 13. August 2010 16:45

Well - at least someone/something agreed with me -

Let me say I totally agree that Apache and IIS can both run one one machine on one NIC. NO doubt whatever. I don't think you can easily get Apache to act as a proxy for IIS by redirecting a port, as I don't see a reverse/return route process. Maybe it can be done, but in my book -- its surely not a XAMPP issue -- if anything its an Apache issue (or network engineering -- or both).

(Edited Later) And sameer posted the Apache fix (which is the missing reverse route)
Good Luck
:shock:

AND -- lots of people want things that either 'don't work right', are outright hacks, or are just dumb ideas (like sticking your finger in the live light socket to see what happens) :D Didn't you watch the YouTube video that BestBuy employee (who got fired I guess) posted about the IPhone avaialability and the fanboy that only wanted an iPhone?. LOL.

:mrgreen: :mrgreen: :mrgreen:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Apache proxy to IIS7

Postby Tyree » 13. August 2010 16:52

Oh, you're right, it's definitely not a xampp issue. I just knew there were smart Apache folks hanging around who may have done this.

From what I've read, this is not a bizarre thing to do. I'm not trying to break some Apache code here or something. People do this sort of thing all the time. Either to target some app running on IIS that utilizes ASP or whatever. This is possible and done often. It's just leveraging the mod_proxy of Apache to point to another port on the same box.

I got it to work pointing to the PC's IP address and port 8080. But, I couldn't get it to work pointing to the url (domain name, etc.). The IP address brought up the IIS default site. So, it definitely works to redirect requests to Apache to IIS...the trick is getting it to point to the correct site on IIS. I've seen it called using Apache to reverse proxy or "front" IIS. People have all kinds of much more complex scenarios where they use it. I just haven't gotten my simple scenario to work! :-D
Tyree
 
Posts: 27
Joined: 10. September 2009 03:02

Re: Apache proxy to IIS7

Postby JonB » 13. August 2010 17:04

respectfully - as a 25+ years network engineer (and owner of a systems integration company) - those band-aid fixes are the bane of networks. 90% of the time they are not documented properly and only ONE person has ever grokked how they work. And when head-banger-the-talented-dork storms off some day in the future, you only need ask "when will this break'?". Because it will. And - rightfully - the Network chief or IT VP should be let go after it is fixed.

(JonB has special dork-detector software called 'manuals' to avoid hiring head-bangers -- if they don't know how to use them, where they are, they don't get the job -- cuase there will be a time I won't be around to bail them out) :shock:

These are all 'my opinions'... and we all know everyoen has them 8)

Good Luck
:mrgreen:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Apache proxy to IIS7

Postby Tyree » 13. August 2010 17:10

Well, two things can be said here....

First, this is my own tinker-toy project. It's not a server that anyone else will care about. I don't have multiple boxes to run this stuff on. I have to test my projects on IIS and Apache...so, I'm making do with what I have.

Secondly, yes, the "headbangers" can be bad, but progress doesn't happen by doing it the same all the time. You have to stretch things to innovate. Think outside the box...manual. Obviously, you don't do this thinking outside the box when it's critical. But, this isn't critical.

Things that seem to be nonsense and dumb one day end up being the norm the next. The world used to be flat, you know?
Tyree
 
Posts: 27
Joined: 10. September 2009 03:02

Re: Apache proxy to IIS7

Postby Nobbie » 13. August 2010 17:17

Tyree wrote:I got it to work pointing to the PC's IP address and port 8080. But, I couldn't get it to work pointing to the url (domain name, etc.).


If i got it right, Apache and IIS are running on the same server and you are simply looking for a proper solution how to get the IIS data via Apache's Reverse Proxy - why do you address your reverse proxy to www.iisserver.com instead of (simply) localhost? The www.iiserver.com produces lots of overhead, lots of DNS requests and finally a bad route instead the pretty small and smart "localhost".

There is no need to have a "public" domain for the reversed proxy, its just vice verse: it is one of the most important advantages of ReverseProxy, that you are able to use a local IP or (as here) simply the localhost, which is not accessible from outside in any other case!

Did i overlook anything or did you?!
Nobbie
 
Posts: 8759
Joined: 09. March 2008 13:04

Re: Apache proxy to IIS7

Postby JonB » 13. August 2010 17:46

well, at least this is a pleasant exchange of ideas.

Note that I mentioed that the real problem(s) was/were undocumented and 'only-one-person-gets-it'. So I am not against thinking outside the box. I am usually the second or third system integrator to be brought in an organization (often by their CPA's, or another integratror/software vendor) as they have usually leraned what does not work - so they are more open to new ideas.

This in in my area of prectice, which is cross-platform engineering. I tend to look for hardware fixes as they are more durable and OS/software update resistant. I also avoid clients that want to quick-fix everything (tha's a lot). I do have my own way of solving the client side problem, I sit in with the business' owners (in whatever manner they may be) and beat their infrastructure into their heads nicely (LOL). They get at least an overview of the pieces - usually with simplified Visio diagrams - so they have an understanding of the weak/crticial points in their process. The we set a monitoring and reporting plan (executive level) so they know the status of those juncture points and it becomes quite easy to get hot spares/redundancy when they know what might break.

When we have to 'fix' things more than one or two times, we have a built-in escalation that says - we need a better solution - and I start tracking one down. Anything that is outside-best-practices, get's written up and is attached to our network documentation (all in Visio) usually as an embedded Word or Excel document.

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Apache proxy to IIS7

Postby Tyree » 13. August 2010 18:51

Nobbie wrote:If i got it right, Apache and IIS are running on the same server and you are simply looking for a proper solution how to get the IIS data via Apache's Reverse Proxy - why do you address your reverse proxy to http://www.iisserver.com instead of (simply) localhost? The http://www.iiserver.com produces lots of overhead, lots of DNS requests and finally a bad route instead the pretty small and smart "localhost".

There is no need to have a "public" domain for the reversed proxy, its just vice verse: it is one of the most important advantages of ReverseProxy, that you are able to use a local IP or (as here) simply the localhost, which is not accessible from outside in any other case!

Did i overlook anything or did you?!

Yes, and you're right, if I had only one site in place of the default site that IIS is serving up, that'd work just fine. But, I using host headers in IIS to use the same IP for more than one site. So, IIS has to be told WHICH site to serve up. Just requesting localhost:8080 or IP:8080 just hits the default IIS site, not what I'm looking for. So, I assumed I had to get the domain name in there to tell IIS which site to use. But, all that's doing is telling Apache to go out to the net and back again to get to the server that the domain points to. And since I don't have 8080 open on my router, it can never get back to it.
Obviously I DON'T want Apache going back out to the net. I want all this to happen on the same box. But, it sounds like when you're using host headers to point to different sites hosted by IIS, it's not possible. Unless perhaps I assign another IP to the box and have each site on its own IP.

JonB,
You are definitely WELL above my level of expertise...well, I don't even really have expertise in networking. I learn enough to get something done, and I usually find a way to get it done. Thank you google and forums (good folks like yourself)! :-D Anyway, that's just how I learn since I don't get paid to do this stuff. I'm more of a designer/illustrator and programmer than I am an engineer of ANY sort! :-) Great thing is, not only do I learn how to do things...I also learn how NOT to do things and where the pit falls are. Once again, from good people like yourself and Nobbie.

So, thanks for your time! (even if you haven't done much more than call my idea dumb.) ;-)
Tyree
 
Posts: 27
Joined: 10. September 2009 03:02

Re: Apache proxy to IIS7

Postby JonB » 13. August 2010 19:28

. Unless perhaps I assign another IP to the box and have each site on its own IP


and the right way to do that is to install another NIC (its called multi-homing). Solves all the issues.

There are definitely 'not in the books' parts to that as well, LOL. I can tell you in ins and outs of that if you choose to do it.

and I will say this for myself, I came to that conclusion earlier (LOL - so I did say soemthing beside 'dumb idea' ):

and you would likely need a second IP address and/or NIC


BTW - I never, ever install servers without at least 2 NICS, one for the local loop and one for the net-facing side, If I need load-balancing I'll add a third. having the second NIC helps sort out issues very quickly. The other tool to learn about is a protocol analyzer such as Wireshark, lets you see what is actaully happening. (its NOT hard to learn)

Cheers
(Sorry -no beer glass lifted smiley on Apache Friends)

:mrgreen: <== close.
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Apache proxy to IIS7

Postby Tyree » 13. August 2010 19:35

So you did say more than, "dumb idea." ;-)

I know it's not CORRECT, but I have assigned two IPs to one card before. It is possible for this purpose. But, I know two NICs is the way to go.
Believe it or not, I do have my servers at work set up that way. :-) Well, the one that connects directly to the net anyway.
Tyree
 
Posts: 27
Joined: 10. September 2009 03:02

Re: Apache proxy to IIS7

Postby JonB » 13. August 2010 20:24

Go ahead and splurge $10-20 on NewEgg for an extra NIC, big spender!
:mrgreen:
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Apache proxy to IIS7

Postby BigWetDog » 18. August 2010 18:00

Have you set the host header in IIS for your site to www.iissite.com?
User avatar
BigWetDog
 
Posts: 148
Joined: 25. February 2010 15:54


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 53 guests