Hi, My pc is using proxy server when connect network, and I ran spring-cloud-netflix-zuul in that. I set gradle and java proxy but zuul can't connect external routing server such as google.com.. Just result in timeout. (although set ribbon and histrix connect time changed) gradle proxy in {HOME}/.gradle/gradle.property and java build with -DproxyHost, proxyPort What's setting I need to use zuul? Thanks.

Comment From: ryanjbaxter

It all might depend on how you are using Zuul. Can you supply your configuration?

Comment From: nicholas-fwang

I set for gradle proxy in {HOME}/.gradle/gradle.properties

systemProp.http.proxyHost={proxy_ip}
systemProp.http.proxyPort={proxy_port}

and maybe for java when build gradle

./gradlew bootRun -Dhttp.proxyHost={proxy_ip} -Dhttp.proxyPort={proxy_port}

application.yml is just routes setting

zuul:
  host:
    connect-timeout-millis: 5000
    socket-timeout-millis: 10000
  routes:
    test:
      path: /test/**
      serviceId: test
      url: http://httpbin.org
    test2:
      path: /test2/**
      serviceId: test2
      url: http://localhost:3010

In case 'test' like external connection, result in timeout fail, with error

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Fri Sep 29 09:01:01 KST 2017
There was an unexpected error (type=Internal Server Error, status=500).
Connect to www.httpbin.org:80 [www.httpbin.org/23.21.245.33, www.httpbin.org/23.21.228.1, www.httpbin.org/23.21.222.104, www.httpbin.org/23.21.55.239, www.httpbin.org/174.129.214.98, www.httpbin.org/23.23.118.21, www.httpbin.org/23.23.151.35, www.httpbin.org/54.225.70.24] failed: connect timed out

but 'test2' like internal connection, result in success. Need additional proxy setting? Thx @ryanjbaxter

Comment From: ryanjbaxter

Can you tell me which version of Spring Cloud you are using? For Dalston we should be using the system properties when creating the Apache HTTP Client. https://github.com/spring-cloud/spring-cloud-netflix/blob/1.3.x/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/SimpleHostRoutingFilter.java#L262

Comment From: nicholas-fwang

@ryanjbaxter

Sorry about my late reply. Yes, I'm using spring cloud 1.3.5 version.

Your link said Request Config, but I think it doesn't have proxy setting

final RequestConfig requestConfig = RequestConfig.custom()
                .setSocketTimeout(this.hostProperties.getSocketTimeoutMillis())
                .setConnectTimeout(this.hostProperties.getConnectTimeoutMillis())
                .setCookieSpec(CookieSpecs.IGNORE_COOKIES).build();

And I solved this problem. In fact, this problem came from routing http client such as Apache Http Client, okhttp, netty.. My env workflow,

My Client Request(curl) --> ZuulProxy --> (SimpleHostRoutingFilter)
 --> (My Proxy) --> External Server

So, if SimpleHostRoutingFilter uses Apache Http Client, I have to proxy setting for this. My solution following.

SimpleHostRoutingFilter.java in spring-cloud-netflix-core module

private CloseableHttpResponse forward(...)
    ...
    HttpHost proxy = new HttpHost({proxy_ip}, {proxy_port});
    ...
    HttpRequest httpRequest = buildHttpRequest(verb, uri, entity, headers, params, request);
    httpRequest.getParams().setParameter(org.apache.http.conn.params.
        ConnRoutePNames.DEFAULT_PROXY, proxy);
    ...

It works well on proxy env.

If you need PR, I can write code setting proxy using config file(application.yml) or RequestContext and will change deprecated version (ConnRoutePNames) to RequestConfig. But, I'm not sure that it needs to zuul proxy :sweat_smile: Thx!

Comment From: devansh-dalal

I tried this.

@ryanjbaxter , I am not sure how to remove the deprecated version ConnRoutePNames? apache.http.HttpRequest does not have any RequestContext way taking the proxy.