需要进行以下配置:

  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就可以根据请求路径返回对应的静态资源

在springcloud的项目中其中一个模块负责存储前端的静态资源需要使用到zuul网关来访问需要进行怎样的配置这个静态资源是放在nginx里面得有个一个服务名叫admin-web端口是80端口

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

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