NGINX-代理传递到具有子域(subdomain.example.com)的网站(example.com)

NGINX-代理传递到具有子域(subdomain.example.com)的网站(example.com),nginx,nginx-reverse-proxy,nginx-location,Nginx,Nginx Reverse Proxy,Nginx Location,我需要代理服务器到另一个服务器有子域(不同的服务器) 我的服务器是,我代理了位置/到domain.com,domain.com有链接到另一个服务器的页面,它是subdomain.abc.com,我如何将我的服务器代理到domain.com和subdomain.domain.com 我成功代理了domain.com上的所有页面,但代理在subdomain.domain.com上不起作用 位置/{}配置 location / { try_files $uri @proxy; } locat

我需要代理服务器到另一个服务器有子域(不同的服务器)

我的服务器是,我代理了位置/到domain.com,domain.com有链接到另一个服务器的页面,它是subdomain.abc.com,我如何将我的服务器代理到domain.com和subdomain.domain.com

我成功代理了domain.com上的所有页面,但代理在subdomain.domain.com上不起作用

位置/{}配置

location / {
    try_files $uri @proxy;
}
location @proxy { 
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    if ($host ~* "subdomain.domain.com") { #this never happen
            proxy_pass (https://)subdomain.domain.com;
    }
    proxy_pass (https://)www.domain.com; (formated because stack blocking full url)
}
位置@proxy{}配置

location / {
    try_files $uri @proxy;
}
location @proxy { 
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    if ($host ~* "subdomain.domain.com") { #this never happen
            proxy_pass (https://)subdomain.domain.com;
    }
    proxy_pass (https://)www.domain.com; (formated because stack blocking full url)
}
我的一些想法是检测用户何时单击(subdomain.domain.com),然后我可以更改主机和远程地址,还可以将代理传递到subdomain.domain.com,但我不确定如何检测用户何时单击菜单导航中的链接

我愿意接受其他想法

谢谢