[Note: my question is not to do with reverse-proxy’s, it is about config but the template for creating a topic wouldn’t allow me to use config
as a tag for this question for some reason].
What I’m trying to do:
I have a working site configuration file that creates a reverse-proxy and currently looks like this:
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;
ssl_client_certificate /path/to/ca.crt;
ssl_crl /path/to/ca.crl;
ssl_verify_client on;
root /var/www/mydomain.com/html;
index index.html index.htm index.nginx-debian.html;
server_name mydomain.com www.mydomain.com;
location / {
try_files $uri $uri/ =404;
}
location /a_thing/ {
proxy_pass http://localhost:8888/;
}
}
However, one of the sites I want to expose uses links with absolute paths that are not under my control. These break if I use a proxy_pass
mapping based on path (e.g. a request to https//mydomain/a_thing
might return a page with a link to /resource
, which plainly won’t work as the site is not at the root, it is at /a_thing
due to the proxying).
I can fix this by opening a separate port for this site that can be let through transparently at the root.
MY QUESTION: in doing this I do not want to duplicate the entire configuration; the majority of it is common, only the listen
port and location
changes.
Where I’m stuck:
How do I best go about structuring my site configuration file to cover multiple sets of listen
/location
while keeping everything else common?
What I’ve already tried:
Nothing yet: I see that the documentation talks of being hierarchical, maybe that is intended to be a hint?