Proxy issue - help please

Discuss practical ways rearrange URLs using mod_rewrite.

Proxy issue - help please

Postby kpc » Tue Nov 18, 2008 1:34 am

Hi. I'm not 100% sure this can be done with mod_rewrite, I'm pretty new tio t all but have been through the tutorials and have been banging my head against the wall :-)

I have two servers:

www.myapache.com
www.mysap.com

one is running plain apache and the other has a SAP application on it, SAP is on the LAN and Apache is in the DMZ (I don't think this is really relevant for the purposes for my question, but thought I'd add it just in case!)

SAP apparently works on services, what I need done is for certain URL's coming into the apache server to then get forwarded to the sap server on the LAN and the content displayed back onto the apache server in the DMZ, I've got mod_rewrite working and can get the apache to forward all requests but can get the proxy to return the results without the server name changing to www.mysap.com or returning a Server Error message!


Here's one example of the URL that users will be clicking:

http://www.myapache.com/sap/bc/webdynpr ... anguage=EN


Here's the Apache rewrite rule: There's about 10 of these, what SAP call services, lines like these 'hrrcf_a_startpage_ext'

RewriteRule ^sap/bc/webdynpro/sap/hrrcf_a_startpage_ext(.*)$ https://www.mysap.com:1443/sap/bc/webdy ... anguage=EN [P,L]

Any help greatly appreciated :-)
kpc
 
Posts: 12
Joined: Tue Nov 18, 2008 12:55 am

Postby richardk » Tue Nov 18, 2008 11:11 am

Does your SAP application do any redirects?
Does any proxying work? Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^test http://example.com/ [P,L]

Is it a Server Error from Apache or the SAP server? What does you error log say about the error?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby kpc » Wed Nov 19, 2008 2:45 am

Hi Richard

I tried the code you sent. Turned out that I didn't have all the required proxy connects enabled for Apache, I enabled them however it then complained about the SSL requirements, which makes sense. Trying to redirect an SSL server through a non-SSL server through a firewall isn't going to work I don't think.

Thanks for getting back to me so fast Richard, much appreciated.
kpc
 
Posts: 12
Joined: Tue Nov 18, 2008 12:55 am

Postby richardk » Wed Nov 19, 2008 7:38 am

I'm not sure about the firewall bit, but i think if Apache has SSL it can make an SSL request, decrypt the SSL response and then send it to the client as non-SSL.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby kpc » Wed Nov 19, 2008 8:09 am

richardk wrote:I'm not sure about the firewall bit, but i think if Apache has SSL it can make an SSL request, decrypt the SSL response and then send it to the client as non-SSL.


Hi Richard

I did try running Apache with SSL but it still refused the connection, probably as they were using different ports, Apache's was 443 (standard) whilst the SAP server is 1443.

Many thanks for your help though :-)
kpc
 
Posts: 12
Joined: Tue Nov 18, 2008 12:55 am

Postby kpc » Fri Nov 21, 2008 3:32 am

Hi Richard

I've managed to sort out the SSL proxy setting, and have been doing some basic tests, just trying to see the SAP login screen with this entry in my .htaccess file:

RewriteRule ^test https://www.mysapserver.com:1443/sap/bc/webdynpro/sap/ [P,L]

In the browser it half works, I get some broken html, half a login screen, and get these errors in the Apache error.log

[Fri Nov 21 11:22:39 2008] [warn] Proxy client certificate callback: (www.myapacheserver.com:443) downstream server wanted client certificate but none are configured
[Fri Nov 21 11:22:39 2008] [error] [client www.mysapserver.com] File does not exist: /srv/www/htdocs/sap, referer: https://www.myapacheserver.com/test

I'm currently using a test server what doesn't have a certified cert on it, hense the warning message, I'm wondering if this could be causing any failures?

Any ideas?
kpc
 
Posts: 12
Joined: Tue Nov 18, 2008 12:55 am

Postby richardk » Fri Nov 21, 2008 1:02 pm

It probably is causing the problems. You could try setting up a self signed certificate. I've never done it, though.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby kpc » Tue Nov 25, 2008 2:46 am

richardk wrote:It probably is causing the problems. You could try setting up a self signed certificate. I've never done it, though.


Hi Richard. I did try setting up the self certification and that worked great, many thanks for your pointer. For Apache it seems just a quick cert isn't enough!

I'm having another small issue which driving me nuts. It's to do with relative URL's and images, i've read through your FAQ and tried somethings but I think it could be a port issue:

Here's my test rewrite:

RewriteRule ^(.*)$ http://www.mysapserver.com:8000/sap/bc/ ... start_int/ [P,L]

The URL gets forwarded but the CSS, JS and Images don't point to the right location so are all broken.

The source of the page is:

<link rel="stylesheet" type="text/css" href="/sap/public/bc/ur/Design2002/themes/sap_tradeshow/ur/ur_ie6.css?6.0.17.0.0">
<script type="text/javascript" language="JavaScript" src="/sap/public/bc/ur/Design2002/js/sapUrMapi_ie6.js?6.0.17.0.0"></script>
<script type="text/javascript" language="JavaScript" src="/sap/public/bc/ur/Design2002/js/languages/urMessageBundle_EN.js?6.0.17.0.0"></script>

I thought all I was doing was a simple redirect and none of the images etc should be broken, could it be the / before the sap in the html which is causing the page to go and look for the images on my apache server instead of the SAP server?

I don't really have access to change the HTML on the SAP server so a rewrite fix would be ideal but I'm not sure how to do it.

Again many thanks for taking a peek
kpc
 
Posts: 12
Joined: Tue Nov 18, 2008 12:55 am

Postby richardk » Tue Nov 25, 2008 4:34 am

The problem is that all paths in the HMTL are relative to the URL in the address bar of the browser.

Either a redirect
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^sap/public/bc/ur/Design2002(/.*)?$ http://www.mysapserver.com:8000/$0 [R=301,L]
RewriteRule ^(.*)$ http://www.mysapserver.com:8000/sap/bc/bsp/sap/hrrcf_start_int/ [P,L]

Or replace R=301 with P to have it proxied.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 7 guests

cron