I have the next setup:
Main server main.com and additional standalone server (additional.com), which should be served via proxy from the subpage url keeping relative paths, etc. main.com/additional
However, trying to setup proxy_pass with location block I can't achieve relative pathes and also static content does not load.
Here is some code:
server {
listen 80;
server_name main.com;
resolver %RESOLVERS%;
set $url "main.com$request_uri";
set $url_additional "https://additional.com";
if ($http_x_forwarded_proto = 'http') {
return 301 https://main.com$request_uri;
}
location /additional {
proxy_pass $url_additional;
}
location / {
rewrite ^/$ /$lang;
proxy_pass $url;
}
}
It tries to load static and index from additional.com/additional, and not additional.com
I have tried with root and alias and some other parameters, but nothing helps :(
What am I missing?