# Gateway Module

Source: https://docs.formance.com/v4.0/deploy/self-hosted/modules/gateway

Stack: v4.0

The Gateway's role is to centralize all incoming connections to your stack. To expose your stack externally, you must route all traffic through it.

## Gateway Object

You can find all the available parameters in [the comprehensive CRD documentation](https://docs.formance.com/stack-api-reference/introduction).

```yaml
apiVersion: formance.com/v1beta1
kind: Gateway
metadata:
  name: formance-dev
spec:
  stack: formance-dev
```

### Expose the Gateway with Ingress

To expose the Gateway externally, we will use an Ingress object. The Ingress will be the entry point to your stack.

```yaml
apiVersion: formance.com/v1beta1
kind: Gateway
metadata:
  name: formance-dev
spec:
  stack: formance-dev
  ingress:
    host: YOUR_DOMAIN
    scheme: http|https
```

### Serving on Multiple Hosts

You can serve a stack on multiple hostnames by adding the `hosts` field alongside `host`. The ingress will contain a rule for each host, and TLS will cover all of them.

```yaml
apiVersion: formance.com/v1beta1
kind: Gateway
metadata:
  name: formance-dev
spec:
  stack: formance-dev
  ingress:
    host: app.example.com
    hosts:
      - app.example.org
      - app.example.net
    scheme: https
```

Additional hosts can also be provided via a [Settings](https://docs.formance.com/v4.0/deploy/self-hosted/config/settings) resource using the `gateway.ingress.hosts` key. Hosts from the setting are merged with those defined on the Gateway CRD. The `{stack}` placeholder is replaced with the stack name.

```yaml
apiVersion: formance.com/v1beta1
kind: Settings
metadata:
  name: gateway-extra-hosts
spec:
  key: gateway.ingress.hosts
  stacks:
    - '*'
  value: "{stack}.example.com, {stack}.example.org"
```
