Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Complicated requirements |
|
Author |
|
tkmilbaugh
Joined: 21 Aug 2025 Posts: 1 Location: USA
|
Posted: Thu 21 Aug '25 14:46 Post subject: Complicated requirements |
|
|
I have an existing, working httpd setup, running in a container, that uses a list of rewrite rules for redirecting obsolete URLs, and a reverse proxy setting to pass all other requests to another app, running in a second container in my Kubernetes pod.
What I want to add to the setup is a list of partial URLs that will serve static content from an attached shared drive. If a request like one of these comes along:
https://my-host.com/this/*
https://my-host.com/that/*
then I will map the request to a static file in:
/path/to/my/content/this
/path/to/my/content/that
Any request not matching any of these patterns will continue to be proxied to my application.
I have read a lot of Apache documentation, but I have not quite figured out how to do this. Is it possible?
TIA |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 395 Location: UK
|
Posted: Fri 22 Aug '25 15:10 Post subject: |
|
|
You should be able to achieve this requirement using suitable AliasMatch directives, followed by selective proxy requests, e.g.:
Code: | # Alias requests for /this/* and /that/* to local shared content
#
AliasMatch "^/this/(.*)$" "/path/to/my/content/this/$1"
AliasMatch "^/that/(.*)$" "/path/to/my/content/that/$1"
|
If the path to your local shared content is outside of the Apache DocumentRoot, you'll need to grant anonymous access to it, e.g.:
Code: | # Grant access to shared content
#
<DirectoryMatch "/path/to/my/content/(this|that)/">
Require all granted
</DirectoryMatch>
|
You can then proxy requests for all other content within a suitable LocationMatch directive (note the following uses a negative lookahead regex), e.g.:
Code: | # Proxy requests other than /this/* /that/*
#
<LocationMatch ^/(?!this|that)(.*)$>
ProxyPass http://my-proxy-host.com/$1
ProxyPassReverse http://my-proxy-host.com/$1
</LocationMatch>
|
|
|
Back to top |
|
|
|
|
|
|