Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 使用Nginx反向代理访问SpringBoot Rest API时出现问题_Spring Boot_Nginx Reverse Proxy - Fatal编程技术网

Spring boot 使用Nginx反向代理访问SpringBoot Rest API时出现问题

Spring boot 使用Nginx反向代理访问SpringBoot Rest API时出现问题,spring-boot,nginx-reverse-proxy,Spring Boot,Nginx Reverse Proxy,我有一个spring启动应用程序。当我通过EclipseIDE运行spring应用程序并通过localhost:8080/api访问它时,我得到了Swagger页面和所有正确的信息 然而,当我试图通过nginx反向代理(localhost:80/test/api)访问在eclipseide上运行的应用程序时,它显示的是404。当我在RestController中将api路径更改为/test/api时,我可以访问该页面 下面是我的nginx配置 location /test/ { set $tes

我有一个spring启动应用程序。当我通过EclipseIDE运行spring应用程序并通过localhost:8080/api访问它时,我得到了Swagger页面和所有正确的信息

然而,当我试图通过nginx反向代理(localhost:80/test/api)访问在eclipseide上运行的应用程序时,它显示的是404。当我在RestController中将api路径更改为/test/api时,我可以访问该页面

下面是我的nginx配置

location /test/ {
set $testapi test-api; 
#proxy_pass http://$testapi:8080; --This one is for other environment
proxy_pass http://host.docker.internal:8080; - When nginx is running locally in a container.
include nginx-route-ws-proxy-settings.conf;
}
我无法理解,当我尝试访问localhost:80/sb/api时,它显示的是404。它重定向到的是谁http://localhost:80/login 因此,nginx无法识别此路径。这里少了一些东西。这是我无法得到的。有人能提出解决办法吗