11.6. HTTP & HTTPS Application

Proxies traffic to an application listening on ports 80 and 443. The assumption is the application uses HTTPS for authentication and HTTP for the general application features. Assuming the login will all take place on port 443, you will need to add the login filters and handlers to the LoginChain. To get started quickly, modify the baseURI to be the IPAddress of your target application. This should allow you to proxy all traffic to the application. Then add the logic for the LoginChain using the flow from one of the login templates.

{
  "heap": {
    "objects": [
    {
        "name": "HandlerServlet",
        "comment": "Entry point that transforms Servlet request to handler request.",
        "type": "HandlerServlet",
        "config": {
            "handler": "DispatchHandler",
        }
    },
    {       
        "name": "DispatchHandler",
        "type": "DispatchHandler",
        "config": {
            "bindings": [   
                {                       
                    "condition": "${exchange.request.uri.scheme == 'http'}",
                    "handler": "OutgoingChain",
                    "baseURI":"http://TARGETIP"
                },  
                {                       
                    "condition": "${exchange.request.uri.path == '/login'}",
                    "handler": "LoginChain",
                    "baseURI":"https://TARGETIP"
                }, 
                {                       
                    "handler": "OutgoingChain",
                    "baseURI":"https://TARGETIP"
                }, 
            ]   
        }   
    },
    {
        "name": "LoginChain",
        "type": "Chain",
        "config": {
            "filters": [],
            "handler": "OutgoingChain" 
        }   
    },
    {
        "name": "OutgoingChain",
        "type": "Chain",
        "config": {
            "filters": ["CaptureFilter"],
            "handler": "ClientHandler" 
        }   
    },
    {   
        "name": "CaptureFilter",
        "type": "CaptureFilter",
        "config": {
            "captureEntity": false,
            "file": "/tmp/gateway.log",
        }       
    },
    {
        "name": "ClientHandler",
        "comment": "Responsible for sending all requests to remote servers.",
        "type": "ClientHandler",
        "config": {
            }
        }
    ]
  },
  "servletObject": "HandlerServlet",
}