---
title: "Targets"
description: "Configure destination endpoints for resource routing and load balancing"
---

## Overview

When you create a resource in Pangolin, you define different targets that specify where traffic should be routed within your network. Each target represents a specific destination that the resource can proxy to when handling incoming requests.

<Note>
Targets are created on the Newt tunnel, enabling traffic to reach destinations on the remote network without requiring additional routing configuration.
</Note>

## How Targets Work

### Target Routing

Targets function as destination endpoints for your resources:

1. **Resource Creation**: When you create a resource, you configure one or more targets
2. **Traffic Routing**: Incoming traffic is routed to the appropriate target based on your configuration
3. **Network Access**: Newt proxy routes traffic to the local network through the tunnel
4. **Direct Connection**: No additional routing is necessary on the remote network

## Multi-Site Targets (v1.9.0+)

With the introduction of update 1.9.0, targets now have sites associated with them. This enhancement provides significant benefits for reliability and load distribution.

### Site-Distributed Resources

You can now configure targets across different sites for the same resource:

<Card title="High Availability">
  Distribute your resources across multiple sites so that if one site goes down, traffic automatically continues to be served from other available sites.
</Card>

<Card title="Load Balancing">
  Set up load balancing across sites to distribute traffic in a round-robin fashion between all available targets.
</Card>

### Load Balancing Requirements

<Warning>
Load balancing between different targets only works when sites are connected to the same node. In Pangolin instances with multiple remote nodes, ensure load balancing occurs on the same node.
</Warning>

To ensure effective load balancing in multi-node environments:

```bash
newt --prefer-endpoint <specific-endpoint> <other-args>
```

<Note>
Pangolin currently does not load balance between nodes, only between targets on the same node.
</Note>

## Path-Based Routing

Path-based routing allows you to direct traffic to different targets based on the request path. This enables sophisticated routing scenarios where different services can handle different parts of your application.

### How Path-Based Routing Works

Each target can be configured with optional path routing parameters:

- **Path**: The path pattern to match against incoming requests
- **Match**: The matching strategy to use when comparing the request path

When a request comes in, Pangolin evaluates the path against all targets and routes traffic to the target with the matching path configuration.

### Match Types

Pangolin supports three different matching strategies:

<Card title="Exact Match">
  **exact**: The request path must match the configured path exactly.
  
  Example: Path `/api/users` with exact match only matches `/api/users`
</Card>

<Card title="Prefix Match">
  **prefix**: The request path must start with the configured path.
  
  Example: Path `/api` with prefix match matches `/api/users`, `/api/orders`, `/api/users/123`, etc.
</Card>

<Card title="Regex Match">
  **regex**: The request path is matched against a regular expression pattern.
  
  Example: Path `^/api/users/[0-9]+$` with regex match matches `/api/users/123` but not `/api/users/abc`
</Card>

<Frame caption="Pangolin UI showing targets with path-based routing configuration">
  <img src="/images/targets_config.png" alt="Targets example"/>
</Frame>

### Load Balancing with Path-Based Routing

When multiple targets have the same path and match configuration, Pangolin will load balance between them using round-robin distribution.

**Example Scenario:**
- Target 1: Path `/api`, Match `prefix`, Address `10.0.1.10:8080`
- Target 2: Path `/api`, Match `prefix`, Address `10.0.1.11:8080`
- Target 3: Path `/web`, Match `prefix`, Address `10.0.1.12:80`

In this configuration:
- Requests to `/api/users` will be load balanced between Target 1 and Target 2
- Requests to `/web/dashboard` will only go to Target 3
