mkopylec / charon-spring-boot-starter

Reverse proxy implementation in form of a Spring Boot starter.
Apache License 2.0
240 stars 54 forks source link

Not removing servlet context from path #74

Closed thiagolocatelli closed 5 years ago

thiagolocatelli commented 5 years ago

This is my configuration

spring:
  application:
    name: revproxy

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

logging:
  level:
    com.github.mkopylec.charon: DEBUG

charon:
  mappings:
    -
      name: http-bin-get
      strip-path: false
      path: /get
      destinations: http://httpbin.org

When I try http://127.0.0.1:8080/revproxy/get, I see the following log:

2018-11-20 17:26:05.958 DEBUG 49800 --- [nio-8080-exec-1] c.g.m.c.core.http.ReverseProxyFilter     : Incoming: GET /revproxy/get
2018-11-20 17:26:06.398 DEBUG 49800 --- [nio-8080-exec-1] c.g.m.charon.core.http.RequestForwarder  : Forwarding: GET /revproxy/get -> http://httpbin.org/revproxy/get 404
2018-11-20 17:26:06.399 DEBUG 49800 --- [nio-8080-exec-1] c.g.m.charon.core.retry.LoggingListener  : Attempt 1 to forward HTTP request using 'http-bin-get' mapping has succeeded

Would the correct assumption be that the application context would be removed from the path when sending the forward request? My understanding was that the final request URI would be http://httpbin.org/get.

mkopylec commented 5 years ago

The context path is always appended to the forward URL. See https://github.com/mkopylec/charon-spring-boot-starter#other-tips

thiagolocatelli commented 5 years ago

Is there an option to remove the context path from the forward URL? I could achieve this by doing path rewrite but it gets complicated. There should be an property to strip the context path. I may work on this on the other issue I am working (#72)