Search code examples
spring-mvcspring-securitynetflix-zuulspring-cloud-netflix

Zuul after login post submit redirecting to legacy original url


I am new to zuul server. I have a legacy system which I am trying to strangulate using zuul proxy server. My zuul server is running on a local machine and my legacy spring MVC system with spring security runs on dedicated physical tomcat server (ex. http://test-server.domain.com/legacySystem). When I enter a local proxy server URL with some path (ex. http://localhost:8080/legacySystem) zuul transparently proxyfies me to legacy server and in the browser address bar I see zuul server address (not the original server address). That's ok. But when, in the current window, I try to login and POST data to server zuul redirects me to original server and then in the browser address bar I see http://test-server.domain.com/legacySystem/login;jsessionid=7152B389D11583056C702BEB0BA20232 address. The server after login post returns with code 302. My zuul config.

---
zuul:
  routes:
      legacySystem:
          path: /legacySystem/**
          url: https://test-server.domain.com/legacySystem/

server:
    port: 8080  

ribbon:
    eureka:
        enabled: false

Can someone help me configuring zuul server properly. The point is that I can't change legacy system's configuration and authentication subsystem. I want to route all requests to legacy system transparently and later I will define some routes that will be used for accessing micro-services. Legacy system uses spring security with simple DAO authentication provider. At this step I don't need any sessions or oAuth tokens between zuul and legacy system. Thanks in advance.


Solution

  • I've been I the same issue. I got solved this by adding this class to my Spring boot Gateway project Documentation reference: https://cloud.spring.io/spring-cloud-netflix/1.4.x/multi/multi__router_and_filter_zuul.html#zuul-redirect-location-rewrite

        import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
        import org.springframework.cloud.netflix.zuul.filters.post.LocationRewriteFilter;
        import org.springframework.context.annotation.Bean;
        import org.springframework.context.annotation.Configuration;
    
        @Configuration
        @EnableZuulProxy
        public class ZuulConfig {
    
            @Bean
            public LocationRewriteFilter locationRewriteFilter() {
                return new LocationRewriteFilter();
            }
        }