Forum Moderators: phranque

Message Too Old, No Replies

Serve ASP Pages through Apache

Should be possible with mod_rewrite?

         

Gibble

4:43 pm on Jul 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ok, I do all my development on my laptop, I run WAMP (Windows, Apache, MySQL, PHP) but currently have the need to do some ASP work as well. I'm running XP Home and am going to install PWS so I can do some vbASP work.

What I would like to be able to do...if at all possible is have PWS running on a different port, since they both can't listen on port 80, and whenever a request comes in for [localhost...] get the output of the page from the PWS server [localhost:81...] but not redirect to that url.

This way, I can theoretically, mix PHP and ASP in the same site...as that is unfortunately what I have to do on this project.

Gibble

8:32 pm on Jul 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think I may have found it...just need to test it.

I believe I need to set IIS to only accept requests from the local computer's IP and have them both use the same document root. With a rewrite rule like this...

RewriteRule (.*\.asp) [192.168.0.101...] [P]

...I think.

lammert

10:13 pm on Jul 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You might use the Apache reverse proxy module for this. In that situation PWS must be installed to listen only on 127.0.0.1 and on a different port than the default port 80, for example 81. For .asp files, Apache forwards the request to 127.0.0.1:81 where PWS is listening. The PWS result is then sent back to the user by Apache.

The visitor does have no direct interacion with PWS. All foreign requests are accepted by Apache, and dependent on how you set up the reverse proxy, some request are handled by Apache directly, and other requests are forewarded to PWS. I use a similar setup for a server handling both ordinary HTML/PHP and JSP. JSP requests are forwarded by Apache to Tomcat.

The Apache manual gives some examples how to setup a proper reverse proxy. You should read the manual carefully, because if you make some wrong settings, your computer will end up to be an open proxy which could be abused.

Gibble

10:53 pm on Jul 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I got PWS installed.

And if I use an .htaccess file with

RewriteEngine on
RewriteRule (.*\.asp) [192.168.0.102:81...]

it works fine, only it redirects...and I want the url to NOT show the :81.

So I change it too

RewriteEngine on
RewriteRule (.*\.asp) [192.168.0.102:81...] [P]

and I get

Forbidden

You don't have permission to access /index.asp on this server.
Apache/2.0.55 (Win32) PHP/5.1.2 Server at localhost Port 80

Any ideas as to what isn't configured properly?

Gibble

6:17 am on Jul 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I got this almost figured out.

I was getting the error becuase dummy me forgot to uncomment the mod_proxy stuff in the httpd.conf file.

Whoops.

The only issue I'm now having, is how can I check what type of file is being loaded 'by default' when someone enters [foo...]

...sometimes it will be index.html, or .php, and sometimes .asp...which I need to check for.

Ideas?

Edit:
actually just having it rewrite the url fom [foo...] to include the filename it's actually loading at the end would work too.

So if it's really loading index.php it is changed to show [foo...] instead of just [foo...]

[edited by: Gibble at 6:31 am (utc) on July 15, 2006]

Gibble

8:02 am on Jul 16, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Anyone?