You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Pennington,Jim" <pe...@oclc.org> on 2020/10/30 14:06:27 UTC

[users@httpd] Apache 2.4.7 - How to parse the host and port and send the request to that host and port

I'm using Apache 2.4.7
I'm currently running and old Apache with customized software and need to change to using a newer Apache.

How do I parse out the server from the request and send the request to the process running on that server (and fixed port)?

Any help is greatly appreciated.
Jim Pennington

A request can come into an Apache running on one server and the request needs to be sent a process running on a different server.
We are using fixed ports and the port in the examples is 1234.

The process that should get the request is derived from the sessionid.
I need to parse out the server and send the request to the process running on that server.

Messages come in with GET or POST and /WebZ/...
Somewhere in the message is sessionid=<server>-<1234>-<...>-<...>

Some requests might have multiple '?' characters.
Some requests might not have any '?' characters.

Here are some example requests.
GET /WebZ/MEdit?sessionid=server09.prod-1234-kgv44z4b-pl2l93:editsessionid=2:catpage=html/corc/catalogue.html:entitymytemplateName=marc?sessionid=server09.prod-1234-kgv44z4b-pl2l93 HTTP/1.1

GET /WebZ/html/corc/helpredirect.html:sessionid=server02.prod-1234-kgvvyfoc-c7bsf2?/WebZ/html/corc/helpredirect.html:sessionid=server02.prod-1234-kgvvyfoc-c7bsf2?http%3A//www.oclc.org/bibformats/en/fixedfield/dtst.html HTTP/1.1

GET /WebZ/html/catexpress/CatExpressBasicSearch.html:sessionid=server09-1234-kgufwyh9-k6bak2:dbname=WorldCat HTTP/1.1

In my httpd.conf file, I have tried several combinations of RewriteCond, RewriteRule and ProxyPassMatch.
The sessionid is typically after the '?' and ProxyPassMatch doesn't find it.

The regular expression below will parse out the server and put it into group $4
/(WebZ)/(.*)(.*?sessionid=([^-]+)-1234)(.*)$


For:
/WebZ/MEdit?sessionid=server09.prod-1234-kgv44z4b-pl2l93:editsessionid=2:catpage=html/corc/catalogue.html:entitymytemplateName=marc?sessionid=server09.prod-1234-kgv44z4b-pl2l93 HTTP/1.1
We would get:
Group 1.	5-9	WebZ
Group 2.	10-136	MEdit?sessionid=server09.prod-1234-kgv44z4b-pl2l93:editsessionid=2:catpage=html/corc/catalogue.html:...
Group 3.	136-164	sessionid=server09.prod-1234
Group 4.	146-159	server09.prod
Group 5.	164-189	-kgv44z4b-pl2l93 HTTP/1.1







---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] RE: [External] Re: [users@httpd] Apache 2.4.7 - How to parse the host and port and send the request to that host and port

Posted by "Pennington,Jim" <pe...@oclc.org>.
The URL should look like http://server:port/WebZ/...

Given the request:
GET /WebZ/MEdit?sessionid=server09.prod-1234-kgv44z4b-pl2l93:editsessionid=2:catpage=html/corc/catalogue.html:entitymytemplateName=marc?sessionid=server09.prod-1234-kgv44z4b-pl2l93 HTTP/1.1

The QUERY_STRING contained: /WebZ/MEdit
So the regular expression never found the sessionid.
To get past the problem of not being able to parse beyond the ‘?’, I tried replacing the ‘?’ with the text {QMRep} – including the curly braces.
This worked until a request contained more than one ‘?’.  The resulting request didn’t contain the parameters between the first and last ‘?’ characters.
It also did not work when a request came in with no ‘?’, which I believe is a poorly formatted request, but that’s what I have to work with.

Here’s the essential parts of the httpd.conf file:

RewriteEngine on
RewriteLog my log location
RewriteLogLevel 5
RewriteCond %{REQUEST_METHOD} ^(TRACK|TRACE)
RewriteRule .* - [F,L]

RewriteCond "%{QUERY_STRING}" "(.+)"
RewriteRule ^/WebZ/(.*)$ /WebZ/$1{QMRep}%1 [PT,NC]

# This one will send the request to the process running on the other server
ProxyPassMatch "/(WebZ)/(.*)({QMRep})(.*?sessionid=([^-]+)-1234)(.*)$" http://$5:1234/$1/$2

#This one will send the request to the process running on the same host as the Apache when ‘?’ was changed to {QMRep}
ProxyPassMatch "/(WebZ)/(.*)({QMRep})(.*)$" http://localhost:1234/$1/$2

# This one will send the request to the process running on the same host as the Apache when the request starts with /WebZ/
ProxyPassMatch  "/(WebZ)/(.*)$" http://localhost:1234/$1/$2


From: Jonathon Koyle <li...@gmail.com>
Sent: Friday, October 30, 2020 11:24 AM
To: users@httpd.apache.org
Subject: [External] Re: [users@httpd] Apache 2.4.7 - How to parse the host and port and send the request to that host and port

What do you expect the final url to look like?  What did you try in mod rewrite, because i believe it can do what you have described so far.

On Fri, Oct 30, 2020, 08:06 Pennington,Jim <pe...@oclc.org>> wrote:
I'm using Apache 2.4.7
I'm currently running and old Apache with customized software and need to change to using a newer Apache.

How do I parse out the server from the request and send the request to the process running on that server (and fixed port)?

Any help is greatly appreciated.
Jim Pennington

A request can come into an Apache running on one server and the request needs to be sent a process running on a different server.
We are using fixed ports and the port in the examples is 1234.

The process that should get the request is derived from the sessionid.
I need to parse out the server and send the request to the process running on that server.

Messages come in with GET or POST and /WebZ/...
Somewhere in the message is sessionid=<server>-<1234>-<...>-<...>

Some requests might have multiple '?' characters.
Some requests might not have any '?' characters.

Here are some example requests.
GET /WebZ/MEdit?sessionid=server09.prod-1234-kgv44z4b-pl2l93:editsessionid=2:catpage=html/corc/catalogue.html:entitymytemplateName=marc?sessionid=server09.prod-1234-kgv44z4b-pl2l93 HTTP/1.1

GET /WebZ/html/corc/helpredirect.html:sessionid=server02.prod-1234-kgvvyfoc-c7bsf2?/WebZ/html/corc/helpredirect.html:sessionid=server02.prod-1234-kgvvyfoc-c7bsf2?http%3A//www.oclc.org/bibformats/en/fixedfield/dtst.html<http://www.oclc.org/bibformats/en/fixedfield/dtst.html> HTTP/1.1

GET /WebZ/html/catexpress/CatExpressBasicSearch.html:sessionid=server09-1234-kgufwyh9-k6bak2:dbname=WorldCat HTTP/1.1

In my httpd.conf file, I have tried several combinations of RewriteCond, RewriteRule and ProxyPassMatch.
The sessionid is typically after the '?' and ProxyPassMatch doesn't find it.

The regular expression below will parse out the server and put it into group $4
/(WebZ)/(.*)(.*?sessionid=([^-]+)-1234)(.*)$


For:
/WebZ/MEdit?sessionid=server09.prod-1234-kgv44z4b-pl2l93:editsessionid=2:catpage=html/corc/catalogue.html:entitymytemplateName=marc?sessionid=server09.prod-1234-kgv44z4b-pl2l93 HTTP/1.1
We would get:
Group 1.        5-9     WebZ
Group 2.        10-136  MEdit?sessionid=server09.prod-1234-kgv44z4b-pl2l93:editsessionid=2:catpage=html/corc/catalogue.html:...
Group 3.        136-164 sessionid=server09.prod-1234
Group 4.        146-159 server09.prod
Group 5.        164-189 -kgv44z4b-pl2l93 HTTP/1.1







---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org<ma...@httpd.apache.org>
For additional commands, e-mail: users-help@httpd.apache.org<ma...@httpd.apache.org>

Re: [users@httpd] Apache 2.4.7 - How to parse the host and port and send the request to that host and port

Posted by Jonathon Koyle <li...@gmail.com>.
What do you expect the final url to look like?  What did you try in mod
rewrite, because i believe it can do what you have described so far.

On Fri, Oct 30, 2020, 08:06 Pennington,Jim <pe...@oclc.org> wrote:

> I'm using Apache 2.4.7
> I'm currently running and old Apache with customized software and need to
> change to using a newer Apache.
>
> How do I parse out the server from the request and send the request to the
> process running on that server (and fixed port)?
>
> Any help is greatly appreciated.
> Jim Pennington
>
> A request can come into an Apache running on one server and the request
> needs to be sent a process running on a different server.
> We are using fixed ports and the port in the examples is 1234.
>
> The process that should get the request is derived from the sessionid.
> I need to parse out the server and send the request to the process running
> on that server.
>
> Messages come in with GET or POST and /WebZ/...
> Somewhere in the message is sessionid=<server>-<1234>-<...>-<...>
>
> Some requests might have multiple '?' characters.
> Some requests might not have any '?' characters.
>
> Here are some example requests.
> GET
> /WebZ/MEdit?sessionid=server09.prod-1234-kgv44z4b-pl2l93:editsessionid=2:catpage=html/corc/catalogue.html:entitymytemplateName=marc?sessionid=server09.prod-1234-kgv44z4b-pl2l93
> HTTP/1.1
>
> GET
> /WebZ/html/corc/helpredirect.html:sessionid=server02.prod-1234-kgvvyfoc-c7bsf2?/WebZ/html/corc/helpredirect.html:sessionid=server02.prod-1234-kgvvyfoc-c7bsf2?http%3A//
> www.oclc.org/bibformats/en/fixedfield/dtst.html HTTP/1.1
>
> GET
> /WebZ/html/catexpress/CatExpressBasicSearch.html:sessionid=server09-1234-kgufwyh9-k6bak2:dbname=WorldCat
> HTTP/1.1
>
> In my httpd.conf file, I have tried several combinations of RewriteCond,
> RewriteRule and ProxyPassMatch.
> The sessionid is typically after the '?' and ProxyPassMatch doesn't find
> it.
>
> The regular expression below will parse out the server and put it into
> group $4
> /(WebZ)/(.*)(.*?sessionid=([^-]+)-1234)(.*)$
>
>
> For:
> /WebZ/MEdit?sessionid=server09.prod-1234-kgv44z4b-pl2l93:editsessionid=2:catpage=html/corc/catalogue.html:entitymytemplateName=marc?sessionid=server09.prod-1234-kgv44z4b-pl2l93
> HTTP/1.1
> We would get:
> Group 1.        5-9     WebZ
> Group 2.        10-136
> MEdit?sessionid=server09.prod-1234-kgv44z4b-pl2l93:editsessionid=2:catpage=html/corc/catalogue.html:...
> Group 3.        136-164 sessionid=server09.prod-1234
> Group 4.        146-159 server09.prod
> Group 5.        164-189 -kgv44z4b-pl2l93 HTTP/1.1
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>