Skip to content

HAL browser redirect fails when proxied through Zuul [DATAREST-815] #1191

@spring-projects-issues

Description

@spring-projects-issues

Tim te Beek opened DATAREST-815 and commented

I have an app called viewer with little more than @SpringBootApplication & @EnableEurekaClient that has spring-data-rest-hal-browser:2.5.1.RELEASE on it's classpath, along with spring cloud Brixton.RC2 dependencies. application.yml only holds the spring.application.name, no context-path. This app connects to a eureka instance and is routed through a Zuul proxy, both also running Brixton.RC2. The Zuul proxy automatically routes /viewer to the backend service.

When I open the root URL from whatever port the viewer app is running on, I'm correctly redirected to /browser/index.html#.

When I open the root URL through my separate Zuul proxy, I'm again redirected to /browser/index.html#, but that fails because the /viewer x-forwarded-prefix header is ignored. Here's a sample response from the actuator /trace page:

{
  "timestamp": 1461596698378,
  "info": {
    "method": "GET",
    "path": "/",
    "headers": {
      "request": {
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
        "upgrade-insecure-requests": "1",
        "user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36",
        "dnt": "1",
        "accept-language": "en-US,en;q=0.8,nl;q=0.6",
        "cookie": "JSESSIONID=",
        "x-forwarded-host": "canary.company.nl",
        "x-forwarded-proto": "https",
        "x-forwarded-prefix": "/viewer",
        "x-forwarded-port": "443",
        "connection": "Keep-Alive",
        "accept-encoding": "gzip",
        "transfer-encoding": "chunked",
        "host": "canary.company.nl:56260"
      },
      "response": {
        "X-Application-Context": "viewer:0",
        "Location": "https://canary.company.nl/browser/index.html#",
        "status": "302"
      }
    }
  }
}

As you can see the Location header does not include the /viewer prefix. Opening /viewer/browser/index.html#/ directly works as expected


Affects: 2.5.1 (Hopper SR1)

Backported to: 2.5.2 (Hopper SR2), 2.4.5 (Gosling SR5)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions