Announcement Announcement Module
Collapse
No announcement yet.
HTTP and HTTPS outbound traffic through proxy Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 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
    Not at the moment. Could you please create JIRA request for this and attach the link to this forum?

    Comment


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

      Comment


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

        Comment


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

          Comment


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

            Comment


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

              Thanks,
              Mark

              Comment

              Working...
              X