为两个应用程序配置位置

问题描述 投票:0回答:1

我需要配置两个在不同端口中运行的spring boot应用程序(机构站点和一个应用程序,但是这两个应用程序在上下文上下文中的根目录“ /”中运行时没有上下文路径,并且我无法更改上下文路径应用程序,因为我需要更改许多文件网址的。

这是配置文件:

server {

        listen 80 default_server;
        listen [::]:80 default_server;

        # Here we should specify the name of server
        server_name server.com.br;

        location = /  {
             proxy_pass http://localhost:8089/;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header X-Forwarded-Proto $scheme;
             proxy_set_header X-Forwarded-Port $server_port;
        }

        location /{some pattern here} {
             proxy_pass http://localhost:8081/login;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header X-Forwarded-Proto $scheme;
             proxy_set_header X-Forwarded-Port $server_port;
        }

        ...
}

我有一个DNS域,所以我想将站点配置为ROOT“ /”,斜杠“ / **”之后的任何内容都将重定向到该应用程序,我想我也必须处理这两个应用程序的静态位置文件。 NGINX可以处理这样的事情吗?

nginx nginx-location
1个回答
0
投票

Nginx无法做到这一点:

location /{some pattern here} {
             proxy_pass http://localhost:8081/login;

如果需要,您可以配置:

location /{some pattern here} {
             proxy_pass http://localhost:8081/;

然后在您的应用中,您自动将http://localhost:8081/->重定向到http://localhost:8081/login

© www.soinside.com 2019 - 2024. All rights reserved.