title: Spring Cloud Gateway in CloudFoundry
body: <p>I've been trying to get my apps to run after deploing them to a CloudFoundry instance. The instance I'm using will not allow to perform requests using http (they will simply timeout) so I have to route all requests to https.</p>
  
  <p>The components/versions I am using are:</p>
  
  <ul>
  <li>Java 10</li>
  <li>Spring Boot 2.0.4.RELEASE/Spring Cloud Finchley.SR1</li>
  <li>spring-cloud-gateway</li>
  <li>spring-cloud-config-server</li>
  <li>spring-cloud-starter-netflix-eureka</li>
  </ul>
  
  <p>The failing config</p>
  
  <p><strong>EurekaClient Config</strong> (in gateway and the backend where the gw should route to)</p>
  
  <pre><code>eureka:
    client:
      serviceUrl:
        defaultZone: ${DISCOVERY_SERVICE_URL:http://localhost:8061}/eureka/
    instance:
      hostname: ${vcap.application.uris[0]:localhost}
      nonSecurePortEnabled: false
      securePortEnabled: true
      securePort: ${server.port}
      statusPageUrl: https://${eureka.instance.hostname}/actuator/info
      healthCheckUrl: https://${eureka.instance.hostname}/actuator/health
      homePageUrl: https://${eureka.instance.hostname}/
      secure-virtual-host-name: https://${vcap.application.application_uris[0]}
  </code></pre>
  
  <p><strong>Gateway Config</strong></p>
  
  <pre><code>spring:
    cloud:
      gateway:
        discovery:
          locator:
            enabled: true
        routes:
        - id: user-service
          uri: lb://user-service
          predicates:
          - Path=/user/**
          filters:
          - RewritePath=/user/(?&lt;segment&gt;.*), /$\{segment}
  </code></pre>
  
  <p>Things I have already tried:</p>
  
  <ul>
  <li>Using <code>lb:https://user-service</code> like described in <a href="https://cloud.spring.io/spring-cloud-gateway/single/spring-cloud-gateway.html#_routetorequesturl_filter" rel="nofollow noreferrer">docs</a> -> Will have no effect as far as I can see</li>
  <li>Use real urls to the apps (<code>uri: https://user-service.cf-instance.io</code>) -> Routing works as expected.</li>
  </ul>
  
  <p>But I do not want to define the urls in my config, they should returned by eureka and build up correctly by the gateway. </p>
  
  <p>Thanks in advance</p>
  
  <p>Edit:</p>
  
  <p>Here is the output of <code>/eureka/apps</code>
  <a href="https://pastebin.com/WP3b6PQG" rel="nofollow noreferrer">https://pastebin.com/WP3b6PQG</a></p>
  
  <p>I am currently working to get the current code into GitHub I will edit this post when I've found the time to get a clear state.</p>
  
  <p>Edit 2:</p>
  
  <p>You can find the full example (With SpringCloudGateway, Eureka, ...) at <a href="https://github.com/konraifen88-home/home-monitor-aio/tree/c2d3f660f654417aca0de2fed915d33b960c0fac" rel="nofollow noreferrer">my GitHub</a>
  This is an running example, the applied config will not use the Eureka. To use Eureka the <code>gateway-service-cloud.yml</code> in config service has to be adopted.</p>
  
  <p><code>
  - id: user-service
          uri: lb://user-service
  </code></p>
  
  <p><strike>Please ignore the documentation service, this will not work yet, I first need to rewrite the path.</strike></p>