> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hop.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Gateways

> Gateways allow you to expose your Hop deployments to your project or the internet

There are 2 types of gateways: Internal or External. External gateways expose
your deployment to the internet under a protocol of your choice, e.g. HTTP.
Internal gateways expose your deployment to your project by giving you an IP
address and customizable internal domain to use.

Currently, both gateway types
[round-robin](https://en.wikipedia.org/wiki/Load_balancing_\(computing\)#Round-robin_scheduling)
requests between containers. In the future, there will be more fine grained
controls for load balancing requests.

## Creating a Gateway

You can create a gateway using the Hop Console or the Hop CLI.

<AccordionGroup>
  <Accordion title="Console">
    1. Navigate to the Gateways tab in an Ignite deployment:

    <Frame>
      <img src="https://mintcdn.com/hopio/cq2ctXa-N8Jv0svA/images/hop-gw-demo-1.webp?fit=max&auto=format&n=cq2ctXa-N8Jv0svA&q=85&s=6b0574351f245cbdfbeb35b32ecb4fb7" alt="" width="1250" height="1260" data-path="images/hop-gw-demo-1.webp" />
    </Frame>

    2. Click on the "Create Gateway" button in the top right:

    <Frame>
      <img src="https://mintcdn.com/hopio/cq2ctXa-N8Jv0svA/images/hop-gw-demo-2.webp?fit=max&auto=format&n=cq2ctXa-N8Jv0svA&q=85&s=f40ffd3d0ce01474ee1fcdb2d97921a3" alt="" width="458" height="286" data-path="images/hop-gw-demo-2.webp" />
    </Frame>

    3. You will be presented with a modal:

    <Frame>
      <img src="https://mintcdn.com/hopio/cq2ctXa-N8Jv0svA/images/hop-gw-demo-3.webp?fit=max&auto=format&n=cq2ctXa-N8Jv0svA&q=85&s=9db0a011ac5c89decb65fe254d104267" alt="" width="1050" height="800" data-path="images/hop-gw-demo-3.webp" />
    </Frame>

    Here, you can select the gateway type and target port.

    Gateway type can be either:

    * External, or
    * Internal

    At the moment, external gateways only support HTTP(S), so there's no option to
    select the protocol yet.

    The target port should be the port your app listens on. The gateway will load
    balance requests between containers on the target port. HTTP gateways will
    automatically handle external HTTP and HTTPS termination on the correct ports
    (80 & 443), so you don't need to run your application on these ports.

    4. Click **Create Gateway**.
  </Accordion>

  <Accordion title="CLI">
    To create a gateway interactively, run the following command:

    ```bash theme={null}
    hop gateways create [--project <project-namespace>]
    ```

    This will take you through the steps to set up a gateway on a deployment.

    You can also create a gateway non-interactively by passing the following flags:

    ```sh theme={null}
    hop gateways create \
      --type <type> \
      --target-port <port> \
      --project [namespace]
    ```
  </Accordion>
</AccordionGroup>

## Adding Custom Domains

By default, every external gateway gets assigned it's own `.hop.sh` domain,
generated using the deployment name. You have the choice to update this
subdomain to something not taken already, or you can add your own custom
domains.

<AccordionGroup>
  <Accordion title="Console">
    1. Head over to the "Domains" page inside your gateway.

    <Frame>
      <img src="https://mintcdn.com/hopio/cq2ctXa-N8Jv0svA/images/hop-gw-demo-4.webp?fit=max&auto=format&n=cq2ctXa-N8Jv0svA&q=85&s=ecf4a83b162c6557199c0d7a228dd9de" alt="" width="718" height="672" data-path="images/hop-gw-demo-4.webp" />
    </Frame>

    2. Here, you can manage the `.hop.sh` domain as well as add your own custom ones.
       To add a custom domain, click on the Attach Domain button in the top right of
       the page.

    3. You will be presented with this modal, where you should enter your desired
       domain.

    <Frame>
      <img src="https://mintcdn.com/hopio/cq2ctXa-N8Jv0svA/images/hop-gw-demo-5.webp?fit=max&auto=format&n=cq2ctXa-N8Jv0svA&q=85&s=657f1b421fa7dc217201f52bedb81c2e" alt="" width="1050" height="572" data-path="images/hop-gw-demo-5.webp" />
    </Frame>

    4. Click **Next**.

    After this, you will be required to create a CNAME record for your previously
    entered domain pointing to Hop.

    5. Details about this record will be shown on screen in a modal after entering the domain. You should add this record to your DNS provider.
  </Accordion>

  <Accordion title="CLI">
    ```sh theme={null}
    hop domains attach [gateway] [domain]
    ```
  </Accordion>
</AccordionGroup>

## Headers

When HTTP requests are sent to your services, they are proxied through our edge network where we append the following headers onto the final request.

### Request Headers

| Header                   | Description                                                                                             |
| ------------------------ | ------------------------------------------------------------------------------------------------------- |
| `x-forwarded-for `       | The IP of the client that made the request as it hits our network                                       |
| `hop-edge-node`          | The node the gateway that proxied your request lives on                                                 |
| `hop-region`             | The region the gateway service lives on                                                                 |
| `hop-gateway-id`         | The ID of your deployment's gateway the request is going through. This will be prefixed with `gateway_` |
| `hop-connecting-country` | The country code of the client that made the request                                                    |
| `hop-connecting-ip`      | The IP of the connecting client                                                                         |
| `x-real-ip`              | The IP of the originating client                                                                        |

### Response Headers

| Header          | Description                                                  |
| --------------- | ------------------------------------------------------------ |
| `hop-edge-node` | The node the gateway that proxied your request lives on      |
| `hop-region`    | The region the gateway service lives on                      |
| `server`        | Indicating the response is from Hop, the value will be `hop` |
