J Freebird
J Freebird

Reputation: 3910

Zuul Routing on Root Path

I want to config zuul to route request to root / to a home page. I tried:

root:
  path: /
  url: http://hostname/home/index.jsp

and

root:
  path: /**
  url: http://hostname/home/index.jsp

But neither of them works. I just got a 404 NOT FOUND. I think the path match config should be similar to those with contexts, such as /service/**, but it's not.

Upvotes: 2

Views: 4065

Answers (1)

code
code

Reputation: 4231

This is what I have done to make this work.

Within Zuul -> controller:

@RequestMapping(value = "/", method = RequestMethod.GET)
public String handleRequest() {
    return "forward:/ux/";
}

Zuul Properties:

zuul:
  addProxyHeaders: true
  routes:
    example-ux:
      path: /ux/**
      stripPrefix: false

Within example-ux Service properties:

server:
  servlet-path: /*
  context-path: /ux

This configuration also solves the problem of static resources resolution. i.e. /static/css static/js etc...

Upvotes: 5

Related Questions