Kong1.0 Create Route with protocols ["https", "tcp"]


#1

Kong 1.0 not support destination port when creating Router with ‘https’ protocol.

But I can create Router with protocols [“https”, “tcp”] and destination port, the request body is:

{
	"name":"router_7088",
	"protocols": ["https", "tcp"],
	"paths": ["/"],
	"regex_priority": 0,
	"strip_path": true,
	"preserve_host": true,
	"snis": null,
	"sources": null,
	"destinations": [{
		"port":7088
	}],
	"service": {
		"id": "dd3775c3-c9cd-4576-a69d-ebfdc0941f4e"
	}	
}

Does this Router make sense If I want to bind different https port with different plugins ? Or does kong 1.0 support different plugins for different ports?


#2

Destination ports can only be used to match L4 Routes. If you define a L7 Route (http or https), this attribute (along with other L4 attributes as of today) cannot be specified. If you specify tcp or tls, this attribute can be specified. That you were able to specify both https and tcp is probably an oversight in Kong.

There is currently no way for Kong to execute a plugin if the connection was accepted on a given port, and not execute it if it is accepted on another port.

A side note: it makes little sense to me that you would define this Route as both L4 and L7. For example, you may end up applying http-only plugins to this Route that will cause errors when the Route gets matched in the L4 mode. In fact I don’t think Kong should let you create such a Route in the first place, but that is probably an oversight on our side. What is the use-case for you to make this Route both L4 and L7?


#3

I just use kong for L7.

I want to bind different https port with different plugins and just find this solution can work when reading ‘kong/router.lua’ and ‘kong/runloop/handler.lua’.

kong/router.lua

if ngx.config.subsystem == "http" then
    function self.exec(ngx)
      local var = ngx.var

      local req_method = ngx.req.get_method()
      local req_uri = var.request_uri
      local req_host = var.http_host or ""
      local src_ip = var.remote_addr
      local src_port = tonumber(var.remote_port, 10)
      local dst_ip = var.server_addr
      local dst_port = tonumber(var.server_port, 10)
      local sni = var.ssl_server_name
      ...
else 
     ...

Is this will be fixed? I think L7 Route with different nginx server_port is a great feature