I'm setting up a reverse proxy for internal testing of various websites via multiple backends.
In order to be able to dynamically add backends, I'm using a wildcard subdomain and parts of the server_name
to extract settings for my Nginx configuration:
server {
listen 80;
server_name ~^(?<domain>.+)\.internal-checks(?<bundle>[0-9])\.mycompany\.com$;
[...]
proxy_set_header Host $domain;
proxy_pass http://10.0.0.$bundle:8080;
So far, so good. What I'm having an issue with is:
How can I replace all the occurrences of http://$domain
with http://$domain.internal-checks$bundle.mycompany.com
within the content I receive from the backends?
This needs to be done in order to adjust all the links in the content to match the reverse proxy's wildcard DNS.
My current attempt is to use subs_filter
. If I'm using hard coded values the substitutions work:
subs_filter http://www.my-site.com http://www.my-site.com.internal-checks1.mycompany.com r;
But whatever combination I tried, subsitution with variables only ends up with the original content. This is my latest shot:
subs_filter http://$domain http://$domain.internal-checks$bundle.mycompany.com r;
How does subs_filter
expect variables to be used?
0 Answers