Results 1 to 7 of 7

Thread: HTTP and HTTPS outbound traffic through proxy

  1. #1
    Join Date
    Feb 2011
    Posts
    22

    Default HTTP and HTTPS outbound traffic through proxy

    Our application server is behind our firewall and inbound HTTP and HTTPS requests get funneled through an Apache HTTPD server sitting in our DMZ to the app server inside the firewall. This works great for inbound messages to our server. The problem is sending outbound messages from our Tomcat server. Since it is behind the firewall it has no outbound ports open so the HttpUrlConnection that is created cant go anywhere.

    The simple solution is to open the HTTP and HTTPS ports in the outbound direction but I want to know if it is possible to pass proxy server information (like a java.net.Proxy class) to Spring Integration so outbound HTTP and HTTPS connections use the proxy server. As I said before, this is only for outbound requests. Inbound is handled just fine.

    Thanks in advance.

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Not at the moment. Could you please create JIRA request for this and attach the link to this forum?

  3. #3
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Actually, can you try setting http.proxyHost and http.proxyPort system properties?

  4. #4
    Join Date
    Feb 2011
    Posts
    22

    Default

    I have created the ticket: https://jira.springsource.org/browse/INT-1827

    I didn't see your second message before I created the ticket. Apologies for that.

    I will try those parameters and see if it works but in the long run it still might be useful to support the java.net.Proxy object. Those system properties would set the proxy for the entire VM and sometimes you don't want all traffic to go over a proxy. The Proxy object enables per-connection proxying.

    As a follow up question, would it be possible to use the Apache HttpClient (by way of the CommonsClientHttpRequestFactory) and set a proxy on the Apache class like below:

    Code:
    HttpClient client = new HttpClient();
    client.getHostConfiguration().setProxy(proxyHost, port);
    That could be a potential workaround until Spring Integration supported the native Java Proxy object.

  5. #5
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,844

    Default

    This is actually supported by the underlying RestTemplate. As you already pointed out, the RestTemplate delegates to a factory for creating the HTTP requests. The "commons" HttpClient accepts the proxy as you've shown, but even the SimpleClientHttpRequestFactory supports a java.net.Proxy instance out-of-the-box. Simply create a bean of type SimpleClientHttpRequestFactory, and then inject your java.net.Proxy instance into that. Then provide a reference to that factory instance from the Spring Integration adapter.

    Also, as you pointed out, the http.proxyHost/http.proxyPort system properties work fine *if* you want to have the proxy configuration applied globally for the VM process.

    Hope that helps.
    -Mark

  6. #6
    Join Date
    Feb 2011
    Posts
    22

    Default

    Thank you both for your help. Much appreciated. Apologies for creating a ticket for a feature that is already supported.

  7. #7
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,844

    Default

    No problem at all. This feature is admittedly not as obvious as it should be. Therefore, we'll keep the issue open but use it as a reminder that we need to document the configuration options for proxy servers.

    Thanks,
    Mark

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •