4
votes

I'm relatively new to spring-cloud, so mayby I haven't found all documentation yet (Spring-Cloud documentation). I found this stackoverflow entry, but unfortunately this did not help me (or I did not understand the answers).

I'm using Spring-Boot 1.3-SNAPSHOT, Spring-Cloud 1.0.3 is included here.

I would like to use Feign and Ribbon for consuming REST Webservices but without using Eureka, Hystrix and Zuul in a first step.

For doing so I annotated the Client-Service method

@FeignClient("modelService")
public interface ProductModelService {...}

and put a configuration like

modelService.ribbon.listOfServers: localhost:8444

into application.properties to use Ribbon without Eureka.

This works fine with HTTP but I'm stuck using HTTPS - I'm not able to find the correct configuration Ribbon uses HTTPS.

Having an annotation like

@FeignClient("https://modelService")
public interface ProductModelService {...}

did not help.

Having a configuration like

modelService.ribbon.isSecure=true

did not help.

How do I have to configure Ribbon so HTTPS secured Rest Webservice are consumed?

2
Could you try with Spring Cloud Brixton.M1 that was recently released? - spencergibb
At the moment I do not have enough time but maybe next week I'm able to test this - currently I removed the Feign Rest client and replaced it by traditional Spring RestTemplate. - flexguse
I have just managed to get this use case working (ribbon & feign but not Eureka etc), although with no significant differences to the above. I am happy to try to help if you are still trying to get this to work. - RobP

2 Answers

4
votes

Recently I've faced with the very same problem and I solved it with the following configuration.

I kept annotation on client class without https prefix, like:

@FeignClient("modelService")
public interface ProductModelService {...}

This configuration ended up being useless for me:

modelService.ribbon.isSecure=true

The main thing which helps me is explicit HTTPs 443 port pointing out, like below:

modelService.ribbon.listOfServers: https://somedomain.com:443
0
votes

The way I've been doing it is to use a custom property to determine whether to use http or https on the ribbon client. I did not use feign, so my example uses RibbonClient instead, but the same approach should work with either(?).

Example:

package some.name.whatever;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.web.client.RestTemplate;

@RibbonClient(name = "random-service")
public class MyClient {

    @Autowired
    @Qualifier("loadBalancedTemplate")
    private RestTemplate rest;

    @Value("${modelService.https}")
    private boolean https;

    private String getServiceUrl() {

        return (https ? "https" : "http") + "://random-service";
    }

    public Integer getRandomNumber() {

        String fullUrl = ;

        return rest.getForEntity(getServiceUrl()+"/randomnumber", Integer.class).getBody();

    }
}