Rewrite to localhost:8000

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

Rewrite to localhost:8000

Postby mcv » 09. December 2013 16:21

I've got XAMPP running on port 80, and a web app on port 8000. I need a rewrite rule so that requests coming in on port 80 are sent to the web app on port 8000, without the browser noticing.

It seems like a fairly simple and obvious thing to do, but I simply cannot figure it out. Usually I get some kind of error message (400 Bad Request, 500 Server Error). The best attempt gave a browser redirect, which isn't what I need, but I figured adding a [P] or maybe [PT] flag would do it, but that resulted in an error.

So what's the correct way to do this?
mcv
 
Posts: 3
Joined: 09. December 2013 16:11
XAMPP Version: 5.5.19
Operating System: Windows 7

Re: Rewrite to localhost:8000

Postby Altrea » 09. December 2013 16:59

We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 6668
Joined: 17. August 2009 13:05
XAMPP Version: 5.5.19
Operating System: W7Ux64

Re: Rewrite to localhost:8000

Postby Nobbie » 10. December 2013 12:15

What you need to configure is a so called "Reverse Proxy". You cannot solve your problem with a Rewrite, as you redirect to a different server and this is evaluated by the browser.
Nobbie
 
Posts: 6760
Joined: 09. March 2008 13:04

Re: Rewrite to localhost:8000

Postby mcv » 10. December 2013 13:39

But I don't want it evaluated by the browser. I want the browser to talk just to Apache, and Apache to hand the request to my app.

I guess I'm going to need something like:

Code: Select all
ProxyPass ^(.*) http://localhost:8000{REQUEST_URI}
ProxyPassReverse ^{.*}http://localhost:8000{REQUEST_URI}


Or maybe just
Code: Select all
ProxyPass /app(.*) http://localhost:8000/app$1
ProxyPassReverse /app(.*) http://localhost:8000/app$1


Although the mod_proxy page sounds like [P] should also work:

A reverse proxy is activated using the ProxyPass directive or the [P] flag to the RewriteRule directive.
mcv
 
Posts: 3
Joined: 09. December 2013 16:11
XAMPP Version: 5.5.19
Operating System: Windows 7

Re: Rewrite to localhost:8000

Postby Nobbie » 10. December 2013 13:50

mcv wrote:I guess I'm going to need something like:

Code: Select all
ProxyPass ^(.*) http://localhost:8000{REQUEST_URI}
ProxyPassReverse ^{.*}http://localhost:8000{REQUEST_URI}


As i wrote above. But this is an ugly ProxyPass.

mcv wrote:
A reverse proxy is activated using the ProxyPass directive or the [P] flag to the RewriteRule directive.


Yes, but you dont need a rewrite, you need a ReverseProxy Only. The easies and best way of creating a working ProxyPass is a VirtualHost with a ProxyPass (so you can pass all Requests to the ReverseProxy). Create any Subdomainname and create a VirtualHost:

Code: Select all
<VirtualHost *:80>
Servername OtherApp
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
</VirtualHost>


And if you enter http://OtherApp into your Browser, it will show the contents of localhost:8000
Nobbie
 
Posts: 6760
Joined: 09. March 2008 13:04

Re: Rewrite to localhost:8000

Postby mcv » 10. December 2013 15:05

Nobbie wrote:
Code: Select all
<VirtualHost *:80>
Servername OtherApp
ProxyPass / http://localhost:8000/
ProxyPassReverse / http://localhost:8000/
</VirtualHost>


And if you enter http://OtherApp into your Browser, it will show the contents of localhost:8000


Thanks! That looks exactly like what I need.
mcv
 
Posts: 3
Joined: 09. December 2013 16:11
XAMPP Version: 5.5.19
Operating System: Windows 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: mark.mcdonald, Nobbie and 60 guests