2020-05-13 21:29:40 +00:00
---
layout: docs
2020-09-01 15:14:13 +00:00
page_title: External <> Internal Services - Ingress Gateways
sidebar_title: External <> Internal Services - Ingress Gateways
2020-05-13 21:29:40 +00:00
description: >-
An ingress gateway enables ingress traffic from services outside the Consul
service mesh to services inside the Consul service mesh. This section details
how to use Envoy and describes how you can plug in a gateway of your choice.
---
2020-06-18 21:27:06 +00:00
# Ingress Gateways
2020-05-13 21:29:40 +00:00
2020-07-08 23:09:00 +00:00
-> **1.8.0+:** This feature is available in Consul versions 1.8.0 and newer.
2020-05-13 21:29:40 +00:00
Ingress gateways enable ingress traffic from services outside the Consul
service mesh to services inside the Consul service mesh. An ingress gateway is
a type of proxy and must be registered as a service in Consul, with the
[kind](/api/agent/service#kind) set to "ingress-gateway". They are an
entrypoint for outside traffic and allow you to define what services should be
exposed and on what port. You configure an ingress gateway by defining a set of
2021-01-13 20:48:48 +00:00
[listeners](/docs/connect/config-entries/ingress-gateway#listeners) that each map
2020-05-13 21:29:40 +00:00
to a set of backing
2021-01-13 20:48:48 +00:00
[services](/docs/connect/config-entries/ingress-gateway#services).
2020-05-13 21:29:40 +00:00
To enable easier service discovery, a new Consul [DNS
2020-11-17 15:03:00 +00:00
subdomain](/docs/discovery/dns#ingress-service-lookups) is provided, on
2020-05-13 21:29:40 +00:00
`<service>.ingress.<domain>`.
2020-06-17 19:43:58 +00:00
For listeners with a
2021-01-13 20:48:48 +00:00
[protocol](/docs/connect/config-entries/ingress-gateway#protocol) other than
2020-06-17 19:43:58 +00:00
`tcp`, multiple services can be specified for a single listener. In this
case, the ingress gateway relies on host/authority headers to decide the
service that should receive the traffic. The host used to match traffic
defaults to the [Consul DNS ingress
2020-11-17 15:03:00 +00:00
subdomain](/docs/discovery/dns#ingress-service-lookups), but can be changed using
2021-01-13 20:48:48 +00:00
the [hosts](/docs/connect/config-entries/ingress-gateway#hosts) field.
2020-06-17 19:43:58 +00:00
2020-05-13 21:29:40 +00:00
![Ingress Gateway Architecture](/img/ingress-gateways.png)
## Prerequisites
Ingress gateways also require that your Consul datacenters are configured correctly:
2020-06-18 21:27:06 +00:00
- You'll need to use Consul version 1.8.0 or newer.
2020-05-13 21:29:40 +00:00
- Consul [Connect](/docs/agent/options#connect) must be enabled on the datacenter's Consul servers.
- [gRPC](/docs/agent/options#grpc_port) must be enabled on all client agents.
Currently, [Envoy](https://www.envoyproxy.io/) is the only proxy with ingress gateway capabilities in Consul.
## Running and Using an Ingress Gateway
2020-06-18 21:27:06 +00:00
For a complete example of how to allow external traffic inside your Consul service mesh,
2020-08-17 16:19:04 +00:00
review the [ingress gateway tutorial](https://learn.hashicorp.com/tutorials/consul/service-mesh-ingress-gateways).
2020-05-13 21:29:40 +00:00
## Ingress Gateway Configuration
Ingress gateways are configured in service definitions and registered with Consul like other services, with two exceptions.
The first is that the [kind](/api/agent/service#kind) must be "ingress-gateway". Second,
the ingress gateway service definition may contain a `Proxy.Config` entry just like a
Connect proxy service, to define opaque configuration parameters useful for the actual proxy software.
For Envoy there are some supported [gateway options](/docs/connect/proxies/envoy#gateway-options) as well as
[escape-hatch overrides](/docs/connect/proxies/envoy#escape-hatch-overrides).
2020-05-20 15:27:25 +00:00
-> **Note:** If ACLs are enabled, ingress gateways must be registered with a token granting `service:write` for the ingress gateway's service name,
`service:read` for all services in the ingress gateway's configuration entry, and `node:read` for all nodes of the services
in the ingress gateway's configuration entry. These privileges authorize the token to route communications to other Connect services.
If the Consul client agent on the gateway's node is not configured to use the default gRPC port, 8502, then the gateway's token
must also provide `agent:read` for its node's name in order to discover the agent's gRPC port. gRPC is used to expose Envoy's xDS API to Envoy proxies.
2020-05-13 21:29:40 +00:00
~> [Configuration entries](/docs/agent/config-entries) are global in scope. A configuration entry for a gateway name applies
2020-07-08 23:09:00 +00:00
across all federated Consul datacenters. If ingress gateways in different Consul datacenters need to route to different
sets of services within their datacenter then the ingress gateways **must** be registered with different names.