Using OpenIG as a regular ReverseProxy similar to NGINX or Apache

This topic has 7 replies, 4 voices, and was last updated 5 years, 8 months ago by Fehmi M’Barek.

  • Author
    Posts
  • #13777
     Fehmi M’Barek
    Participant

    Hi @ all,

    is there a possibilty to use OpenIG as a Reverse Proxy similar to NGINX or Apache in order to manage different WebSite on different Hosts? (On NGINX they call it “Server Blocks”)

    It would be very helpful if you would help me out with the router configuration (config.json) and also the different routes.

    Thanks in advanced.

    #13781

    Yes you can handle request targeting different hosts with OpenIG.

    Part of the configuration depends on your DNS settings (that maps openig.example.com, www.acme.com, to the IP where your web container hosting OpenIG runs).

    The other part depends on your routes configuration, you have to check in the condition that the incoming request has the hostname you want:

    {
      "condition": "${request.uri.host == 'www.acme.com' and ...}"
    }
    

    You don’t need any config.json to make that work, just provide a route JSON configuration in your ${openig.base}/config/routes/ directory.

    #13785
     Fehmi M’Barek
    Participant

    Hi Guillaume,

    first of all, thank you for the prompt reply.

    Do this listing look like a wright Route?

    {
        "heap": {
            "objects": [
                {
                    "name": "myHandler",
                    "type": "ClientHandler",
                    "config": {
    			"baseURI": "http://1.1.1.1:8080"
    		}
                }
            ]
        },
        "handler": "myHandler",
        "condition": "${request.uri.host, == 'www.acme.com')}"
    }
    

    Thanks in advanced

    #13787

    baseURI should be a top level attribute, next to condition
    Otherwise, that LGTM

    #13802
     Laurent Vaills
    Participant

    By the way, be careful : there is also typo in your condition : a comma after the host.

    So here is the configuration, with the Guillaume’s advice (baseURI is a decorator, not a raw config of ClientHandler) :

    
    {
        "heap": {
            "objects": [
                {
                    "name": "myHandler",
                    "type": "ClientHandler",
                    "baseURI": "http://1.1.1.1:8080"
                }
            ]
        },
        "handler": "myHandler",
        "condition": "${request.uri.host == 'www.acme.com')}"
    }
    
    #13810
     Fehmi M’Barek
    Participant

    thanks a lot Laurent

    #14321
     Kabi Patt
    Participant

    Hi
    I am new to OpenIG. Few questions on the configuration mentioned above.

    (1) “baseURI”: “http://1.1.1.1:8080” :- Is this the IP where the target app “www.acme.com” is hosted ?
    (2) When to use config.json file vs “../routes/xxx.json” . Can the config.json file be empty ?

    Thanks,
    Kabi

    • This reply was modified 5 years, 8 months ago by Kabi Patt.
    #14336
     Fehmi M’Barek
    Participant

    Hi Kabi,

    (1) yes.
    (2) It is not necessary to have a config.json in /home/user/.openig/config. If you don’t create one, the a default configuration will be load. In my environment I am not using a config.json. I have only routes in /home/user/.openig/config/routes

    best regards,
    Fehmi

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

©2022 ForgeRock - we provide an identity and access platform to secure every online relationship for the enterprise market, educational sector and even entire countries. Click to view our privacy policy and terms of use.

Log in with your credentials

Forgot your details?