Skip to content

Commit 06064d4

Browse files
committed
adds TCP guide
1 parent 7caf1e3 commit 06064d4

File tree

6 files changed

+272
-17
lines changed

6 files changed

+272
-17
lines changed

content/docs/courses/zero-fundamentals/advanced-routes.mdx

+75-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ sidebar_position: 5
77

88
# Build Advanced Routes
99

10-
In this guide, you'll build advanced routes in the Zero Console. To do that, you'll configure route settings in Pomerium Zero and test them against an upstream service called HTTPbin.
10+
In this guide, you'll build advanced routes by exploring some of the route settings available in Pomerium Zero.
1111

1212
:::note **Before You Start**
1313

@@ -22,20 +22,18 @@ Each tutorial builds on the same configuration files. In this tutorial, you’ll
2222

2323
:::
2424

25-
## Advanced route configuration settings
25+
## What are advanced routes?
2626

27-
Pomerium provides route-level settings that allow you to customize how the Proxy service handles requests. More advanced configurations allow identity header pass-through, path and prefix rewrites, and request and response header modifications.
27+
Pomerium provides many route-level settings that allow you to customize how the Proxy service handles requests. More advanced configurations allow identity header pass-through, path and prefix rewrites, and request and response header modifications.
2828

29-
For the purposes of this guide, we will only review select settings from the list below to give you an idea of how you can further configure routes for your use case:
29+
In the Zero Console, these settings are organized into categories, like TLS Settings and Headers settings. For the purposes of this guide, we will test only select settings from the categories listed below:
3030

3131
- **Headers**
3232
- **Path Matching**
3333
- **Path Rewriting**
34-
- **Prefix & Prefix Rewrite**
35-
- **Redirects**
36-
- **Direct Response**
34+
- **Advanced settings**
3735

38-
### Configure HTTPBin
36+
### Set up HTTPBin
3937

4038
To test these settings, we will configure Pomerium Zero and Docker Compose to host an HTTPBin server. If you’re not familiar with [HTTPBin](https://httpbin.org/), it’s a call-and-response HTTP server you can use to test (you guessed it) HTTP requests and responses.
4139

@@ -133,7 +131,7 @@ Now, configure [**Set Request Headers**](/docs/reference/routes/headers#set-requ
133131

134132
![Setting and removing HTTP request headers in the Zero Console](./img/advanced-routes/set-and-remove-request-headers.png)
135133

136-
Apply your changeset and test the request again. You'll notice that the set request header was added to the request, and the specified JWT claim headers were removed:
134+
Apply your changeset and test the request again. You'll notice that the request header was added to the request, and the specified JWT claim headers were removed:
137135

138136
![Reviewing the response body in HTTPBin after setting and removing HTTP headers](./img/advanced-routes/set-and-remove-headers-response-body.png)
139137

@@ -282,7 +280,7 @@ In the Zero Console:
282280
1. Select **Path Matching**
283281
1. In the **Prefix** field, enter `/admin`
284282

285-
If you append the `/admin` endpoint to your route, Pomerium should direct you to the `/admin` only page. If you don't append `/admin`, you will see a 404 error:
283+
If you append the `/admin` endpoint to your route, Pomerium should direct you to the `/admin` only page. If you don't append `/admin`, you will see a `404` error:
286284

287285
![Adding the /admin prefix to the Node server route](./img/advanced-routes/nodeserver-prefix-setting.gif)
288286

@@ -308,3 +306,70 @@ Great job! You've configured several advanced routes in Pomerium Zero.
308306
In the next guide, you'll secure TCP routes and access an SSH service.
309307

310308
Go to [TCP Routes](/docs/courses/zero-fundamentals/tcp-ssh).
309+
310+
#### Configuration file state
311+
312+
At this point, your Docker Compose file should look like:
313+
314+
```yaml title="docker-compose.yaml"
315+
services:
316+
pomerium:
317+
image: pomerium/pomerium:v0.25.1
318+
ports:
319+
- 443:443
320+
restart: always
321+
environment:
322+
POMERIUM_ZERO_TOKEN: <CLUSTER_TOKEN>
323+
XDG_CACHE_HOME: /var/cache
324+
volumes:
325+
- pomerium-cache:/var/cache
326+
networks:
327+
main:
328+
aliases:
329+
- verify.<CLUSTER_SUBDOMAIN>.pomerium.app
330+
- authenticate.<CLUSTER_SUBDOMAIN>.pomerium.app
331+
verify:
332+
image: cr.pomerium.com/pomerium/verify:latest
333+
networks:
334+
main:
335+
aliases:
336+
- verify
337+
grafana:
338+
image: grafana/grafana:latest
339+
ports:
340+
- 3000:3000
341+
networks:
342+
main: {}
343+
environment:
344+
- GF_AUTH_SIGNOUT_REDIRECT_URL=https://grafana.<CLUSTER_SUBDOMAIN>.pomerium.app/.pomerium/sign_out
345+
- GF_AUTH_JWT_ENABLED=true
346+
- GF_AUTH_JWT_HEADER_NAME=X-Pomerium-Jwt-Assertion
347+
- GF_AUTH_JWT_EMAIL_CLAIM=email
348+
- GF_AUTH_JWT_USERNAME_CLAIM=sub
349+
- GF_AUTH_JWT_JWK_SET_URL=https://authenticate.<CLUSTER_SUBDOMAIN>.pomerium.app/.well-known/pomerium/jwks.json
350+
- GF_AUTH_JWT_CACHE_TTL=60m
351+
- GF_AUTH_JWT_AUTO_SIGN_UP=true
352+
volumes:
353+
- ./grafana-storage:/var/lib/grafana
354+
355+
httpbin:
356+
networks:
357+
main: {}
358+
image: kennethreitz/httpbin
359+
ports:
360+
- 80:80
361+
362+
nodeserver:
363+
networks:
364+
main: {}
365+
build:
366+
context: ./app
367+
ports:
368+
- 5001:5001
369+
370+
networks:
371+
main: {}
372+
373+
volumes:
374+
pomerium-cache:
375+
```

content/docs/courses/zero-fundamentals/certificates.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
id: certificats
2+
id: certificates
33
title: Certificates
44
sidebar_label: 07. Certificates
55
sidebar_position: 7
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
---
2+
id: tcp-routes
3+
title: TCP Routes
4+
sidebar_label: 06. TCP Routes
5+
sidebar_position: 6
6+
---
7+
8+
# Secure TCP and SSH Connections
9+
10+
Now that you’ve built several routes, you'll learn how to proxy TCP and SSH connections with Pomerium Zero.
11+
12+
:::note **Before You Start**
13+
14+
Make sure you’ve completed the following tutorials:
15+
16+
- [**Build a Simple Route**](/docs/courses/zero-fundamentals/build-routes)
17+
- [**Build a Simple Policy**](/docs/courses/zero-fundamentals/build-policies)
18+
- [**Single Sign-on with JWTs**](/docs/courses/zero-fundamentals/single-sign-on)
19+
- [**Build Advanced Policies**](/docs/courses/zero-fundamentals/advanced-policies)
20+
- [**Build Advanced Routes**](/docs/courses/zero-fundamentals/advanced-routes)
21+
22+
Each tutorial builds on the same configuration files. In this guide, you'll proxy TCP connections to a Redis database and a remote OpenSSH server.
23+
24+
:::
25+
26+
## Background
27+
28+
When replacing a traditional VPN, there are often non-HTTP based applications you still need to reach. Pomerium can provide the same type of protection to these services with [Pomerium CLI](/docs/deploy/clients/pomerium-cli), a client-side application to proxy TCP connections.
29+
30+
In this guide, you'll proxy TCP connections to a Redis database and an OpenSSH server.
31+
32+
Pomerium’s CLI client comes with a `tcp` command that you can use to secure this connection.
33+
34+
## Prerequisites
35+
36+
To complete this guide, you need:
37+
38+
- [Pomerium CLI](/docs/deploy/clients/pomerium-cli) to proxy TCP connections between end-users and services behind Pomerium
39+
40+
:::note
41+
42+
This guide assumes you've installed the Pomerium CLI client to your system.
43+
44+
:::
45+
46+
## Test Pomerium CLI installation
47+
48+
Test the installation:
49+
50+
```shell-session
51+
$ pomerium-cli
52+
Usage:
53+
pomerium-cli [command]
54+
55+
Available Commands:
56+
cache commands for working with the cache
57+
completion Generate the autocompletion script for the specified shell
58+
help Help about any command
59+
k8s commands for the kubernetes credential plugin
60+
tcp creates a TCP tunnel through Pomerium
61+
version version
62+
63+
Flags:
64+
-h, --help help for pomerium-cli
65+
-v, --version version for pomerium-cli
66+
67+
Use "pomerium-cli [command] --help" for more information about a command.
68+
```
69+
70+
## Add Redis and OpenSSH services
71+
72+
Add the Redis and OpenSSH server configurations to your Docker Compose file:
73+
74+
```yaml
75+
redis:
76+
image: redis:latest
77+
networks:
78+
main: {}
79+
expose:
80+
- 6379
81+
82+
myssh:
83+
image: linuxserver/openssh-server:latest
84+
networks:
85+
main: {}
86+
expose:
87+
- 2222
88+
environment:
89+
PASSWORD_ACCESS: "true"
90+
USER_PASSWORD: supersecret
91+
USER_NAME: user
92+
```
93+
94+
## Add routes in Pomerium Zero
95+
96+
Create a Redis route:
97+
98+
1. Create a new route for your Redis database
99+
1. In **From**, select **tcp+https://** in the protocol dropdown menu
100+
1. Enter your external route and append `:6379` to it
101+
1. For example, `redis.super-hero-7645.pomerium.app:6379`
102+
1. In **To**, enter `tcp://redis:6379`
103+
1. In **Policies**, select `Any Authenticated User`
104+
105+
![Building the Redis route in the Zero Console](./img/tcp/redis-service.png)
106+
107+
Create an OpenSSH route:
108+
109+
1. Create a new route for the OpenSSH server
110+
1. In **From**, select **tcp+https://** in the protocol dropdown menu
111+
1. Enter your external route and append `:22` to it
112+
1. For example, `myssh.super-hero-7645.pomerium.app:22`
113+
1. In **To**, enter `tcp://myssh:2222`
114+
115+
![Building the OpenSSH route in the Zero Console](./img/tcp/ssh-server.png)
116+
117+
Save your changes and apply them.
118+
119+
## Connect to Redis
120+
121+
In a terminal, run the following command:
122+
123+
```shell-session
124+
$ pomerium-cli tcp redis.<CLUSTER_SUBDOMAIN>.pomerium.app:6379 --listen localhost:6379
125+
```
126+
127+
If set up correctly, Pomerium will open your browser to authenticate you. This will establish a TCP connection.
128+
129+
In a separate terminal window, run the following `redis-cli` command:
130+
131+
```bash
132+
$ redis-cli info
133+
# Server
134+
redis_version:7.0.5
135+
redis_git_sha1:00000000
136+
redis_git_dirty:0
137+
redis_build_id:d9291579292e26e3
138+
redis_mode:standalone
139+
os:Linux 6.3.13-linuxkit aarch64
140+
arch_bits:64
141+
monotonic_clock:POSIX clock_gettime
142+
multiplexing_api:epoll
143+
atomicvar_api:c11-builtin
144+
gcc_version:10.2.1
145+
process_id:1
146+
process_supervised:no
147+
run_id:bc1b8bcd39f1e51d615f5739158e6ae964f7e724
148+
tcp_port:6379
149+
server_time_usec:1713989553900448
150+
uptime_in_seconds:64
151+
uptime_in_days:0
152+
hz:10
153+
configured_hz:10
154+
lru_clock:2713521
155+
executable:/data/redis-server
156+
config_file:
157+
io_threads_active:0
158+
```
159+
160+
We truncated the Redis response above for the sake of brevity, but it demonstrates that you successfully proxied a TCP connection to the Redis service.
161+
162+
## Connect to SSH server
163+
164+
In a terminal, run the following command:
165+
166+
```shell-session
167+
$ pomerium-cli tcp myssh.<CLUSTER_SUBDOMAIN>.pomerium.app:22 --listen :2222
168+
```
169+
170+
If set up correctly, Pomerium will open your browser to authenticate you. This will establish a TCP connection.
171+
172+
In a separate terminal window, run:
173+
174+
```bash
175+
ssh user@myssh.<CLUSTER_SUBDOMAIN>.pomerium.app -p 2222
176+
```
177+
178+
This will prompt the SSH server to request a password. The credentials are hardcoded in the Docker Compose file:
179+
180+
- **USER_PASSWORD:** supersecret
181+
- **USER_NAME:** user
182+
183+
After authenticating, you should see a greeting from OpenSSH, like:
184+
185+
```shell-session
186+
$ user@myssh.<CLUSTER_SUBDOMAIN>.pomerium.app's password:
187+
Welcome to OpenSSH Server
188+
189+
f157ed9f7a38:~$
190+
```
191+
192+
Awesome! You successfully configured two services that take advantage of Pomerium's TCP capabilities to proxy requests.
193+
194+
## Up Next: Certificates
195+
196+
Go to [Certificates](/docs/courses/zero-fundamentals/certificates)

content/docs/courses/zero-fundamentals/tcp-ssh.mdx

-6
This file was deleted.

0 commit comments

Comments
 (0)