需要进行以下配置:

  1. 在 Zuul 网关的配置文件中,设置路由规则,将请求路径中包含 '/admin-web/**' 的请求转发到 admin-web 服务,示例配置如下:
zuul:
  routes:
    admin-web:
      path: /admin-web/**
      url: http://admin-web:80
  1. 在 Nginx 配置文件中,将 admin-web 服务的静态资源所在目录配置为 Nginx 的静态资源目录,示例配置如下:
server {
    listen 80;
    server_name localhost;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    location /admin-web/ {
        root   /path/to/admin-web;
        index  index.html index.htm;
    }
}

其中,'/path/to/admin-web' 为 admin-web 服务的静态资源所在目录。这样,当 Zuul 网关转发请求到 admin-web 服务时,Nginx 就可以根据请求路径返回对应的静态资源。

Spring Cloud Zuul 网关配置:访问 Nginx 上的静态资源

原文地址: https://www.cveoy.top/t/topic/nu8r 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录