I have a NGINX configuration with two virtual hosts (server {}
blocks): one serving a human-readable site on the primary domain, and the other acting as a reverse-proxy for a specialized service on a subdomain.
http {
<...>
server {
listen 443 ssl http2;
server my.tld;
<...>
location / {
root /srv/http;
<...>
}
}
server {
listen 443 ssl http2;
server svc.my.tld;
<complex reverse-proxy setup with many location blocks>
}
}
For some reason, some clients of the specialized service send their requests to the primary domain (i. e. I see my.tld/api/endpoint
instead of svc.my.tld/api/endpoint
in the logs). I cannot fix these clients. They also don't follow redirects.
Is there any way to transparently redirect those requests into the correct server {}
block, without duplicating the whole reverse-proxy configuration in the main server block?