Issue with httpClientConfig

24 views
Skip to first unread message

Ralf Callenberg

unread,
Jan 24, 2023, 1:43:21 AM1/24/23
to membrane-monitor
Hello,

i've got a simple configuration with the following router:
<router>
    <!--
        <httpClientConfig>
            <proxy host="proxy.mydomain.com" port="80" />
        </httpClientConfig>
    -->
   
        <serviceProxy name="info" port="8000" >
            <path>/info</path>
            <groovy>
                exc.setResponse(Response.ok("info ok").build())
                RETURN
            </groovy>
        </serviceProxy>
       
        <serviceProxy name="app" port="8000" >
            <path>/app</path>
             <target host="app.mydomain.com" port="8080"/>
        </serviceProxy>

        <serviceProxy name="root" port="8000" >
            <path>/</path>
            <groovy>
                exc.setResponse(Response.ok("root ok").build())
                RETURN
            </groovy>
        </serviceProxy>
    </router>

Everything works as expected.On the server we need an HTTP Proxy. But if I uncomment the httpClientConfig, the service proxy "app" no longer works. Addressing  localhost:8000  using a browser hangs, there is no forwarding to app.mydomain.com. Removing the httpClientConfig - forwarding works again.

Any idea what could be the problem? Or is there another way to handle HTTP proxies (setting http_proxy or setting httpHost and httpPort when starting the JVM does not work)?

Regards,
Ralf

Tobias Polley

unread,
Jan 24, 2023, 3:45:25 AM1/24/23
to membrane-monitor
Hi Ralf,

probably I don't get it: You wrote "Removing the httpClientConfig - forwarding works again." This would mean that you actually don't need a proxy. - While everything is working?

Membrane does not honor http_proxy (or similar) environment variables and does not honor http.proxyHost (or similar) Java Settings.

If you enable the <proxy> for the 'global' <httpClientConfiguration/>, as shown in your example, Membrane attempts to use the specified proxy (proxy.mydomain.com:80) for all outbound connections. If you get a timeout, I would guess it is a firewall issue.

Maybe raising the log level from INFO to DEBUG or even TRACE in conf/log4j2.xml can help you debug this issue.

Best, Tobias

Ralf Callenberg

unread,
Jan 24, 2023, 8:41:45 AM1/24/23
to membrane-monitor
Hi Tobias,
thanks for the quick reply. It's appreciated.

This configuration is a stripped down version of the one I am actually using. There I have OAuth plus reverse proxy and couldn't get it to work on the Linux server (which has an HTTP proxy). When only running it as a reverse proxy it doesn't need the HTTP proxy and works fine without the <proxy>. With OAuth the communication with the authentication server requires the HTTP Proxy, therefore I included the <proxy>. And this I didn't get to run. It always was hanging after the login, when the callback came in. (It worked all well on my Windows desktop where there is no HTTP proxy needed and therefore <proxy> isn't used) Then I realized, it also hangs if I switch off OAuth again but leave the <proxy> in.

This is the logging with the <proxy> included and without. One can see, that until the line " Message:169 - createBody" both sequence of events are the same, then it deviates. "ChunkedBody:42 - ChunkedInOutBody constructor" and " ChunkedBody:153 - writeStreamed" are only present in the case without <proxy>.  With the proxy after " HttpServerHandler:239 - exchange set completed" the process just finishes, whereas without <proxy> it continues (" HttpEndpointListener:146 - Accepted connection from /<IP of server>:6325" and so on)

Regards,
Ralf

with <proxy>
14:07:32,366 DEBUG Router:142 - loading spring config: file:/var/applications/membrane/conf/proxies.xml
14:07:33,858 DEBUG AbstractXmlElement:38 - <accessControl>
14:07:33,861 DEBUG AbstractXmlElement:38 - <resource>
14:07:33,866 DEBUG AbstractXmlElement:38 - <clients>
14:07:33,869 DEBUG AbstractXmlElement:38 - <hostname>
14:07:33,869 DEBUG AbstractXmlElement:47 - </hostname>
14:07:33,871 DEBUG AbstractXmlElement:38 - <ip>
14:07:33,871 DEBUG AbstractXmlElement:47 - </ip>
14:07:33,872 DEBUG AbstractXmlElement:38 - <ip>
14:07:33,873 DEBUG AbstractXmlElement:47 - </ip>
14:07:33,873 DEBUG AbstractXmlElement:47 - </clients>
14:07:33,874 DEBUG AbstractXmlElement:47 - </resource>
14:07:33,874 DEBUG AbstractXmlElement:47 - </accessControl>
14:07:33,908  INFO HttpEndpointListener:103 - listening at '*:8443'
14:07:33,913  INFO HttpEndpointListener:103 - listening at '*:9000'
14:07:33,916 DEBUG HotDeploymentThread:71 - Spring Hot Deployment Thread started.
14:07:33,919  INFO Router:307 - Membrane Service Proxy 4.8.7 up and running!
14:07:41,894 TRACE ConnectionManager:212 - closing old connections
14:07:48,359 DEBUG HttpEndpointListener:146 - Accepted connection from /<IP of server>:56411
14:07:48,370 DEBUG HttpServerHandler:77 - New ServerThread created. 1
14:07:48,536 DEBUG Request:140 - createBody
14:07:48,537 DEBUG Request:143 - empty body created
14:07:48,543 DEBUG InterceptorFlowController:104 - Invoking request handler: Rule Matching Interceptor on exchange: [time:Jan 24, 2023,requestURI:/app]
14:07:48,544 DEBUG RuleManager:223 - Host from rule: *;   Host from parameter rule key: ffm04esbapp01m.mydomain.com:8443
14:07:48,545 DEBUG RuleMatchingInterceptor:99 - Matching Rule found for RuleKey ffm04esbapp01m.mydomain.com:8443 GET /app 8443 172.17.140.221
14:07:48,546 DEBUG InterceptorFlowController:104 - Invoking request handler:   Store Interceptor on exchange: [time:Jan 24, 2023,requestURI:/app]
14:07:48,558 DEBUG InterceptorFlowController:104 - Invoking request handler: Dispatching Interceptor on exchange: [time:Jan 24, 2023,requestURI:/app]
14:07:48,559 DEBUG DispatchingInterceptor:81 - destination: http://localhost:8080/app
14:07:48,560 DEBUG InterceptorFlowController:104 - Invoking request handler: Reverse Proxy on exchange: [time:Jan 24, 2023,requestURI:/app]
14:07:48,561 DEBUG InterceptorFlowController:104 - Invoking request handler: User Feature on exchange: [time:Jan 24, 2023,requestURI:/app]
14:07:48,562 DEBUG InterceptorFlowController:104 - Invoking request handler: HTTPClient on exchange: [time:Jan 24, 2023,requestURI:/app]
14:07:48,563 DEBUG HttpClient:194 - try # 0 to http://localhost:8080/app
14:07:48,564 DEBUG ConnectionManager:145 - connection requested for localhost:8080 via proxy.mydomain.com:80
14:07:48,565 DEBUG ConnectionManager:147 - Number of connections in pool: 0
14:07:48,574 DEBUG Connection:111 - Opened connection on localPort: 56664
14:07:48,585 DEBUG Message:169 - createBody
14:07:48,587 DEBUG InterceptorFlowController:126 - Invoking response handler: Reverse Proxy on exchange: [time:Jan 24, 2023,requestURI:http://localhost:8080/app]
14:07:48,588 DEBUG InterceptorFlowController:126 - Invoking response handler:   Store Interceptor on exchange: [time:Jan 24, 2023,requestURI:http://localhost:8080/app]
14:07:48,593 DEBUG Connection:139 - Closing HTTP connection LocalPort: 56664
14:07:48,599 DEBUG HttpServerHandler:239 - exchange set completed
14:07:49,893 TRACE ConnectionManager:212 - closing old connections

And this without <proxy>
14:06:58,655 DEBUG HttpEndpointListener:146 - Accepted connection from /<IP of server>:63258
14:06:58,665 DEBUG HttpServerHandler:77 - New ServerThread created. 1
14:06:58,848 DEBUG Request:140 - createBody
14:06:58,849 DEBUG Request:143 - empty body created
14:06:58,855 DEBUG InterceptorFlowController:104 - Invoking request handler: Rule Matching Interceptor on exchange: [time:Jan 24, 2023,requestURI:/app]
14:06:58,855 DEBUG RuleManager:223 - Host from rule: *;   Host from parameter rule key: ffm04esbapp01m.mydomain.com:8443
14:06:58,856 DEBUG RuleMatchingInterceptor:99 - Matching Rule found for RuleKey ffm04esbapp01m.mydomain.com:8443 GET /app 8443 172.17.140.221
14:06:58,857 DEBUG InterceptorFlowController:104 - Invoking request handler:   Store Interceptor on exchange: [time:Jan 24, 2023,requestURI:/app]
14:06:58,868 DEBUG InterceptorFlowController:104 - Invoking request handler: Dispatching Interceptor on exchange: [time:Jan 24, 2023,requestURI:/app]
14:06:58,868 DEBUG DispatchingInterceptor:81 - destination: http://localhost:8080/app
14:06:58,869 DEBUG InterceptorFlowController:104 - Invoking request handler: Reverse Proxy on exchange: [time:Jan 24, 2023,requestURI:/app]
14:06:58,869 DEBUG InterceptorFlowController:104 - Invoking request handler: User Feature on exchange: [time:Jan 24, 2023,requestURI:/app]
14:06:58,870 DEBUG InterceptorFlowController:104 - Invoking request handler: HTTPClient on exchange: [time:Jan 24, 2023,requestURI:/app]
14:06:58,870 DEBUG HttpClient:194 - try # 0 to http://localhost:8080/app
14:06:58,871 DEBUG ConnectionManager:145 - connection requested for localhost:8080
14:06:58,871 DEBUG ConnectionManager:147 - Number of connections in pool: 0
14:06:58,875 DEBUG Connection:111 - Opened connection on localPort: 37496
14:06:58,877 DEBUG Message:169 - createBody
14:06:58,878 DEBUG ChunkedBody:42 - ChunkedInOutBody constructor
14:06:58,879 DEBUG InterceptorFlowController:126 - Invoking response handler: Reverse Proxy on exchange: [time:Jan 24, 2023,requestURI:/app]
14:06:58,881 DEBUG InterceptorFlowController:126 - Invoking response handler:   Store Interceptor on exchange: [time:Jan 24, 2023,requestURI:/app]
14:06:58,881 DEBUG ChunkedBody:153 - writeStreamed
14:06:58,882 DEBUG Connection:139 - Closing HTTP connection LocalPort: 37496
14:06:58,886 DEBUG HttpServerHandler:239 - exchange set completed
14:06:58,917 DEBUG HttpEndpointListener:146 - Accepted connection from /<IP of server>:63259
14:06:58,918 DEBUG HttpServerHandler:77 - New ServerThread created. 2
14:06:58,988 DEBUG Request:140 - createBody
14:06:58,988 DEBUG Request:143 - empty body created
14:06:58,989 DEBUG InterceptorFlowController:104 - Invoking request handler: Rule Matching Interceptor on exchange: [time:Jan 24, 2023,requestURI:/app/]
 ... etc ...
Reply all
Reply to author
Forward
0 new messages