summaryrefslogtreecommitdiff
path: root/docs/configuration/service/https.md
blob: 83d13d5a3e440b3af0ef6f61c99ee88459ac96cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
---
myst:
  html_meta:
    description: |
      VyOS provides an HTTP API for running operational-mode commands
      and managing configuration. The API is available as both REST and
      GraphQL, served by an HTTPS listener with configurable TLS.
    keywords: http-api, https, rest, graphql, api-key, jwt, tls, cors
---

(http-api)=

# HTTP API

VyOS provides an HTTP API. You can use it to run operational-mode
commands or to change or delete configuration. The API is available as
both a REST API and a GraphQL API.

For REST API request examples, endpoints, and authentication details,
see {ref}`vyosapi`.

```{note}
If no PKI certificate is configured for the service, VyOS automatically
generates a self-signed certificate. This is not recommended for production use.
```

## Configuration

### HTTPS listener

```{cfgcmd} set service https listen-address \<address\>

**Configure a local IPv4 or IPv6 address on which the HTTPS listener
accepts incoming connections.**

The IP address must already be assigned to a local interface. Repeat
the command to configure multiple IP addresses.

When unset, the listener accepts incoming connections on all local IP
addresses.
```

Example:

```none
set service https listen-address 192.0.2.1
set service https listen-address 2001:db8::1
```

```{cfgcmd} set service https port \<1-65535\>

**Configure the TCP port on which the HTTPS listener accepts incoming
connections.**

The default is 443.
```

```{note}
If the chosen port is already in use by another service, the commit
fails.
```

Example:

```none
set service https port 8443
```

```{cfgcmd} set service https vrf \<name\>

**Bind the HTTPS listener to the specified
{abbr}`VRF (Virtual Routing and Forwarding)` instance.**

The VRF must already be configured under `set vrf name <name>`.
```

Example:

```none
set service https vrf mgmt
```

```{cfgcmd} set service https allow-client address \<address\>

**Restrict access to the HTTPS API endpoints to the specified IPv4 or
IPv6 address or prefix.**

Repeat the command to allow multiple IP addresses or prefixes.

When unset, the API accepts connections from any IP address.
```

Example:

```none
set service https allow-client address 192.0.2.0/24
set service https allow-client address 2001:db8::/32
```

```{cfgcmd} set service https enable-http-redirect

**Enable redirection of incoming HTTP requests (port 80) to HTTPS.**

The redirect sends traffic to the default HTTPS port (443). If you
have changed the HTTPS port, the redirect will not work.
```

Example:

```none
set service https enable-http-redirect
```

```{cfgcmd} set service https request-body-size-limit \<1-256\>

**Configure the maximum size, in megabytes, of an HTTP request body
accepted by the listener.**

Requests exceeding this limit are rejected.

The default is 1.
```

Example:

```none
set service https request-body-size-limit 10
```

### TLS

```{cfgcmd} set service https tls-version \<1.2 | 1.3\>

**Enable a specific TLS protocol version for the HTTPS listener.**

Repeat the command to enable multiple protocol versions.

By default, both TLS 1.2 and TLS 1.3 are enabled.
```

Example:

```none
set service https tls-version 1.3
```

```{cfgcmd} set service https certificates certificate \<name\>

**Bind a TLS certificate from the PKI subsystem to the HTTPS
listener.**

The certificate must already be defined under
`set pki certificate <name>` with both a certificate and a private
key.
```

Example:

```none
set service https certificates certificate my-server-cert
```

```{cfgcmd} set service https certificates ca-certificate \<name\>

**Bind a {abbr}`CA (Certificate Authority)` certificate from the PKI
subsystem to the HTTPS listener.**

The CA must already be defined under `set pki ca <name>`. The CA
certificate is appended to the TLS certificate to form a full chain
presented to clients during the TLS handshake.
```

Example:

```none
set service https certificates ca-certificate my-internal-ca
```

```{cfgcmd} set service https certificates dh-params \<name\>

**Choose Diffie-Hellman parameters from the PKI subsystem for the HTTPS
listener.**

The parameters must already be defined under `set pki dh <name>` with
a key size of at least 2048 bits. The parameters are used by DHE
cipher suites in TLS 1.2. TLS 1.3 does not use them.
```

Example:

```none
set service https certificates dh-params my-dh-2048
```

### API authentication

```{cfgcmd} set service https api keys id \<name\> key \<apikey\>

**Configure an HTTP API key to authenticate REST requests, and GraphQL
requests unless GraphQL is switched to JWT token authentication.**

The key is specified in plaintext and grants full access to the API.

At least one key must be configured to use the REST API. GraphQL can
run without keys if JWT token authentication is enabled.
```

Example:

```none
set service https api keys id MY-HTTPS-API-ID key 'MY-HTTPS-API-PLAINTEXT-KEY'
```

### REST

```{cfgcmd} set service https api rest

**Enable the REST API for managing VyOS over HTTPS.**
```

Example:

```none
set service https api rest
```

```{cfgcmd} set service https api rest strict

**Reject delete requests on the `/configure` endpoint when the target
configuration path does not exist.**

Without this flag, such requests succeed silently.
```

Example:

```none
set service https api rest strict
```

```{cfgcmd} set service https api rest debug

**Log detailed error messages to the systemd journal when API
configuration requests fail.**

Without this flag, only short error messages are logged.
```

Example:

```none
set service https api rest debug
```

### GraphQL

```{cfgcmd} set service https api graphql introspection

**Enable GraphQL schema introspection.**

Authenticated clients can then query the endpoint for the full schema.
Disabled by default, and typically kept disabled in production due to
security concerns.
```

Example:

```none
set service https api graphql introspection
```

```{cfgcmd} set service https api graphql authentication type \<key | token\>

**Configure the authentication type for GraphQL requests:**

- `key`: Uses the API keys configured in `service https api keys`.
- `token`: Uses {abbr}`JWT (JSON Web Token)` tokens.

The default is `key`.
```

Example:

```none
set service https api graphql authentication type token
```

```{cfgcmd} set service https api graphql authentication expiration \<60-31536000\>

**Configure the lifetime, in seconds, of JWT tokens.**

The default is 3600.
```

Example:

```none
set service https api graphql authentication expiration 86400
```

```{cfgcmd} set service https api graphql authentication secret-length \<16-65535\>

**Configure the length, in bytes, of the shared secret used to sign
JWT tokens.**

The default is 32.
```

Example:

```none
set service https api graphql authentication secret-length 64
```

```{cfgcmd} set service https api graphql cors allow-origin \<origin\>

**Configure which websites (origins) can read responses from the
GraphQL API in a browser, using
{abbr}`CORS (Cross-Origin Resource Sharing)`.**

Repeat the command to allow multiple origins.
```

Example:

```none
set service https api graphql cors allow-origin https://app.example.com
```

## Example

The minimal configuration for a working REST API requires enabling REST
and configuring at least one API key:

```none
set service https api keys id MY-HTTPS-API-ID key MY-HTTPS-API-PLAINTEXT-KEY
set service https api rest
```