Spring-cloud-netflix: Zuul and Static Resources

Created on 8 Mar 2015  路  1Comment  路  Source: spring-cloud/spring-cloud-netflix

First: My goal is to have Zuul frontend all components of Spring Cloud. i.e. Eureka, Hystrix, others. I am finding that I can't get static resources to route properly. They show 404's in the browser.

Eureka example:

Access URL from Zuul: http://hostname/discovery/ this returns the page without any of the static resources.

In the browser it shows trying to get http://hostname/eureka/css/wro.css results in a 404.

The static resource is located @ http://hostname/discovery/eureka/css/wro.css

I have tried the following Zuul route configs:

No route config, just using default.

and

zuul:
    routes:
        discovery:
            path: /discovery/**
            stripPrefix: true

and

zuul:
    routes:
        discovery:
            path: /discovery/**
            stripPrefix: false

This same error happens with other Spring based applications such as VanRoy's spring-cloud-dashboard.

I did add a HAL browser to a different service and used a static folder under resources "using default static resource mapping behavior of Spring Boot" and that works properly.

Most helpful comment

Looks like I found a way to solve this problem.

If you have a UI based service being accessed from Zuul setting the context-path will bring the application and static resources into parity.

I now have Eureka and the Hystrix Dashboard working from the Zuul URL:
Below is what was changed in each to resolve the above issue.

server:
    context-path: /${spring.application.name}

Note: Anyone wondering about the value of having the Spring Cloud Config, Spring Cloud Bus and RabbitMQ will soon discover that a URL change to Eureka means you have to refresh every service to establish discovery again. I have a decent number of services and it would take a good amount of time to find the dynamic AWS URL for each to refresh the config properties. The cloud bus meant /bus/refresh in Rabbit and everything came up.

>All comments

Looks like I found a way to solve this problem.

If you have a UI based service being accessed from Zuul setting the context-path will bring the application and static resources into parity.

I now have Eureka and the Hystrix Dashboard working from the Zuul URL:
Below is what was changed in each to resolve the above issue.

server:
    context-path: /${spring.application.name}

Note: Anyone wondering about the value of having the Spring Cloud Config, Spring Cloud Bus and RabbitMQ will soon discover that a URL change to Eureka means you have to refresh every service to establish discovery again. I have a decent number of services and it would take a good amount of time to find the dynamic AWS URL for each to refresh the config properties. The cloud bus meant /bus/refresh in Rabbit and everything came up.

Was this page helpful?
0 / 5 - 0 ratings