📗
Janus Manual
  • Introduction
  • Installation
    • Docker
  • Quick Start
    • Authenticating
    • Add an endpoint
    • Modify (Update/Delete) an endpoint
    • Add Plugins
    • Authentication
    • Adding your API - File System
  • Clustering/HA
  • Proxy Reference
    • Terminology
    • Overview
    • Routing capabilities
    • Load Balacing
    • Request Host header
      • Using wildcard hostnames
      • The preserve_host property
    • Request URI
      • The strip_path property
      • The append_path property
    • Request HTTP method
    • Routing priorities
    • Conclusion
  • Plugins
    • Basic
    • Organization
    • Body Limit
    • Circuit Breaker
    • Compression
    • CORS
    • OAuth
    • Rate Limit
    • Request Transformer
    • Response Transformer
    • Retry
  • Auth
    • OAuth 2.0
  • Misc
    • Health Checks
    • Monitoring
    • Tracing
  • Known Issues
    • Stale HTTP Keep-Alive
  • Upgrade Notes
    • 2.x to 3.x
    • 3.6.x to 3.7.x
Powered by GitBook
On this page

Was this helpful?

  1. Proxy Reference

Request URI

Another way for Janus to route a request to a given upstream service is to specify a request URI via the proxy.listen_path property. To satisfy this field's condition, a client request's URI must be prefixed with one of the values of the proxy.listen_path field.

For example, in an API configured like this:

{
    "name": "My API",
    "proxy": {
        "listen_path": "/hello/*",
        "upstreams" : {
            "balancing": "roundrobin",
            "targets": [
                {"target": "http://my-api.com"}
            ]
        },
        "methods": ["GET"],
    }
}

The following requests would match the configured API:

GET /hello HTTP/1.1
Host: my-api.com
GET /hello/resource?param=value HTTP/1.1
Host: my-api.com
GET /hello/world/resource HTTP/1.1
Host: anything.com

For each of these requests, Janus detects that their URI is prefixed with one of the API's proxy.listen_path values. By default, Janus would then forward the request upstream with the untouched, same URI.

When proxying with URIs prefixes, the longest URIs get evaluated first. This allow you to define two APIs with two URIs: /service and /service/resource, and ensure that the former does not "shadow" the latter.

PreviousThe preserve_host propertyNextThe strip_path property

Last updated 4 years ago

Was this helpful?