Code Monkey home page Code Monkey logo

Comments (11)

mikz avatar mikz commented on August 22, 2024

You can set the server_name in the admin interface. Then just expose it via a router and it will be accessible through that route.

from apicast.

VinayBhalerao avatar VinayBhalerao commented on August 22, 2024

But the server_name always remain the same since they have only one domain i.e api.company.com.This is the domain where the request is sent and then depending on the URL path it is routed to correct backend.

As the domain is always same, how does correct location block and service_id is triggered?

We mainly do this by identifying the URL path by location eg: location /v1/test {} and then route it correct upstream by manually editing the nginx conf file

from apicast.

mikz avatar mikz commented on August 22, 2024

The server name should be unique. If they have more than server block with the same server_name the path based routing won't work. It will route to just one of them. If they have one domain, have just one service & one gateway. We just support domain routing. This is not a problem of this Docker Gateway.

/cc @vramosp

from apicast.

VinayBhalerao avatar VinayBhalerao commented on August 22, 2024

That is the point. The server_name is always same since it's one domain. The customer blindly followed our tutorial https://support.3scale.net/guides/infrastructure/docker-openshift and expects that when he routes using URL, correct backend should be invoked.

Let me explain with example:

There are 3 endpoints on 3 different backends. My wish is to access the docker gateway api.mystation.com and access all three backend endpoints.

On 3scale UI, I configure api.mystation.com as public facing URL and this is the server_name which always remain the same.

/movies --> movies.api.com
/music --> music.api.com
/location  --> location.api.com

On 3scale side we configure using 3 separate services, thus creating 3 server blocks

For above three services, 3scale generates below service_ids

movies.api.com --> 2555555
music.api.com --> 244444
location.api.com --> 233333

Whey I run the docker image and scripts, the gateway downloads the file per the format on #22 (comment)
This is wrong and it doesn't understand where to route the calls

whereas the correct format would be only one server block and depending on the URL path route the call to correct service id

http {

  upstream backend_abc {
  server movies.api.com:443 fail_timeout=30;
}

upstream backend_def {
  server music.api.com:443 fail_timeout=30;
}

upstream backend_xyz {
  server location.api.com:443 fail_timeout=30;
}

  server {
    server_name api.mystation.com;

    location /movies {
    set $service_id 2555555;
    proxy_pass https://backend_abc;
    ...
    }

    location /music {
    set $service_id 2444444;
    proxy_pass https://backend_def;
    ...
    }

    location /location {
    set $service_id 2333333;
    proxy_pass https://backend_xyz;
    ...
    }
  }
}

@vramosp I would be available to go over the scenario again. Let me know.

from apicast.

mikz avatar mikz commented on August 22, 2024

@VinayBhalerao the gateway never supported that. It always supported only host based routing (without customizations).

What we could do, is leverage the redirect_uri parameter of the mapping rule and have one meta meta service as router.

That would mean creating:

  • service api.mystation.com
  • service movies.api.com
  • service music.api.com
  • ...

And the meta service api.mystation.com would have those path mappings & redirect_url set to route to the different service.

That way the routed would still have a server block for ever service, but each would have unique server name.

We probably should show some warning, when your services don't have unique server name, because that just won't work.

from apicast.

mikz avatar mikz commented on August 22, 2024

#62 shows how to add new server with custom configuration. Feel free to contribute more complete example with routing.

from apicast.

mikz avatar mikz commented on August 22, 2024

Also there is feature to use both host and mapping rules to determine a service. #71

That would solve your issues. I can help you to test this.

from apicast.

mayorova avatar mayorova commented on August 22, 2024

I guess this is solved by #71?
We need to add some documentation though.

from apicast.

mikz avatar mikz commented on August 22, 2024

I'd say it is solved by #71. Someone just has to try it. I'll add a flag to the openshift template to enable that feature in #114.

from apicast.

mayorova avatar mayorova commented on August 22, 2024

@mikz I tried it and it worked for me. Will see if I can add a description of how it works somewhere.

from apicast.

vramosp avatar vramosp commented on August 22, 2024

@mikz @andrewdavidmackenzie Tested and seems to be working fine. Thank you for your help @mayorova !

from apicast.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.