1

I am having difficulty figuring out how to use environment variables in ProxyPassMatch.

My general format:

<LocationMatch "(?<THING>Regex)">
    ProxyPassMatch http://example.com:8000/%{env:MATCH_THING}
    ProxyPassReverse /
</LocationMatch>

I have %{MATCH_THING}e logged and the log shows that the regex-captured URL is capturing what I want it to capture, but every time I try to access the LocationMatched URL through the proxy, I get 404 Not Found.

It works when I directly try http://example.com:8000/RegexCapturedURL.
Where RegexCapturedURL = %{MATCH_THING}e;

Here are some of the ProxyPassMatch lines I have tried so far:

  • ProxyPassMatch http://example.com:8000/%{env:MATCH_THING}
  • ProxyPassMatch http://example.com:8000/%{MATCH_THING}
  • ProxyPassMatch http://example.com:8000/%{THING}
  • ProxyPassMatch http://example.com:8000/%{MATCH_THING}e

What am I doing wrong or not understanding correctly?

1 Answer 1

0

I Found this to be be very close to what you are looking.

https://stackoverflow.com/a/11852428/1459214

you can try the regex first to include more broad matching and then check to see if your regex is the issue, as given in the answer

main post is here: https://stackoverflow.com/questions/11852238/proxypassmatch-with-proxypassreverse

4
  • i feel like i dont need to check my regex. as I mentioned, i am logging the regex matched portion and it shows exactly what I am trying to capture. do your references still apply? or do you think I have other issues that I am not understanding regarding the regex? Apr 14, 2017 at 20:01
  • additionally, this is associated with apache 2.4. i believe after 2.4.8 apache ignores numbered groups and only uses named grouping. I believe your reference utilizes numbered group. I think my issue is more of a problem with how to use environment variables in proxypassmatch than a problem with the regex. but I am happy to be corrected. (i have tried using a more broad matching regex before, but it doesnt really do anything in my case since my regex already captures the whole string when it should be captured) Apr 14, 2017 at 20:08
  • You have already said that if you use direct URL it works. and the only variable you are introducing is your Regex. I am not sure id your Regex is causing that isse , especially syntaxwise. So I am just suggesting another way to narrow down if your regex perhaps is the issue... The worst part here is there is no other way you can test your original URL+regex Apr 14, 2017 at 20:11
  • Ok Just saw your comment.. Apr 14, 2017 at 20:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .