Announcement Announcement Module
No announcement yet.
HTTP and HTTPS outbound traffic through proxy Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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 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
    Not at the moment. Could you please create JIRA request for this and attach the link to this forum?


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


      • #4
        I have created the ticket:

        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 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:

        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
          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 instance out-of-the-box. Simply create a bean of type SimpleClientHttpRequestFactory, and then inject your 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.


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


            • #7
              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.