You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/nginx-one/api/nginx_configuration.md
+52-48Lines changed: 52 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,6 @@ The workflows for managing NGINX Configs for Instances, Config Sync Groups, and
23
23
You can retrieve the current NGINX Config for an Instance, Config Sync Group, or Staged Config using a `GET` request. This is useful for making updates based on the existing configuration.
24
24
25
25
Use the following curl command to retrieve the current NGINX Config for a specific Instance. Replace `<tenant>`, `<namespace>`, `<instance-object-id>`, and `<token-value>` with your actual values.
26
-
27
26
```shell
28
27
curl -X GET "https://<tenant>.console.ves.volterra.io/api/nginx/one/namespaces/<namespace>/instances/<instance-object-id>/config" \
@@ -39,47 +38,57 @@ To update the NGINX Config for a Config Sync Group or Staged Config, replace `in
39
38
40
39
The response will include the current NGINX Config in JSON format. This response is saved to a file (e.g., `current_config.json`) for editing.
41
40
42
-
## Updating the NGINX Config
43
-
44
41
You can modify the NGINX Config using either `PUT` or `PATCH` requests. The `PUT` method replaces the entire NGINX Config, while the `PATCH` method allows you to update specific fields without affecting the rest of the configuration.
45
42
46
-
1.**Update the NGINX Config for an Instance using `PUT`**:
43
+
## How to base64 encode a file for JSON request
47
44
48
-
When using the `PUT` method, ensure that your request body includes all necessary contents, as it will overwrite the existing configuration.
49
-
The following example demonstrates how to update the NGINX Config for a specific Instance using `PUT`. Replace `<tenant>`, `<namespace>`, `<instance-object-id>`, and `<token-value>` with your actual values. The request body should contain the complete NGINX Config in JSON format.
50
-
```shell
51
-
curl -X PUT "https://<tenant>.console.ves.volterra.io/api/nginx/one/namespaces/<namespace>/instances/<instance-object-id>/config" \
52
-
-H "Authorization : APIToken <token-value>" \
53
-
-H "Content-Type: application/json" \
54
-
-d @updated_config.json
55
-
```
56
-
- `<tenant>`: Your tenant name for organization plans.
57
-
- `<namespace>`: The namespace your Instance belongs to.
58
-
- `<instance-object-id>`: The object_id of the NGINX Instance you want to update the NGINX Config for.
59
-
- `<token-value>`: Your API Token.
60
-
61
-
2. **Update the NGINX Config for an Instance using `PATCH`**:
62
-
63
-
When using the `PATCH` method, you only need to include the files you want to update in your request body.
64
-
The following example demonstrates how to update the NGINX Config fora specific Instance using `PATCH`. Replace `<tenant>`, `<namespace>`, `<instance-object-id>`, and `<token-value>` with your actual values. The request body should contain only the fields you want to updatein JSON format.
65
-
```shell
45
+
When updating the NGINX Config, file `contents` must be base64 encoded. You can use the following command to base64 encode a file:
46
+
47
+
```shell
48
+
base64 -w 0 -i <path-to-your-file>
49
+
```
50
+
This command reads the file at `<path-to-your-file>` and outputs its base64 encoded content in a single line (due to the `-w 0` option). You can then copy this encoded string and include it in your JSON request body. On some systems the `-w` option may not be available, in which case you can use:
51
+
```shell
52
+
base64 -i <path-to-your-file>| tr -d '\n'
53
+
```
54
+
55
+
## Update the NGINX Config for an Instance using `PUT`
56
+
57
+
When using the `PUT` method, ensure that your request body includes all necessary contents, as it will overwrite the existing configuration.
58
+
The following example demonstrates how to update the NGINX Config for a specific Instance using `PUT`. Replace `<tenant>`, `<namespace>`, `<instance-object-id>`, and `<token-value>` with your actual values. The request body should contain the complete NGINX Config in JSON format.
59
+
```shell
60
+
curl -X PUT "https://<tenant>.console.ves.volterra.io/api/nginx/one/namespaces/<namespace>/instances/<instance-object-id>/config" \
61
+
-H "Authorization : APIToken <token-value>" \
62
+
-H "Content-Type: application/json" \
63
+
-d @updated_config.json
64
+
```
65
+
-`<tenant>`: Your tenant name for organization plans.
66
+
-`<namespace>`: The namespace your Instance belongs to.
67
+
-`<instance-object-id>`: The object_id of the NGINX Instance you want to update the NGINX Config for.
68
+
-`<token-value>`: Your API Token.
69
+
70
+
## Update the NGINX Config for an Instance using `PATCH`
71
+
72
+
When using the `PATCH` method, you only need to include the files you want to update in your request body.
73
+
The following example demonstrates how to update the NGINX Config for a specific Instance using `PATCH`. Replace `<tenant>`, `<namespace>`, `<instance-object-id>`, and `<token-value>` with your actual values. The request body should contain only the fields you want to update in JSON format.
- `<tenant>`: Your tenant name for organization plans.
72
-
- `<namespace>`: The namespace your Instance belongs to.
73
-
- `<instance-object-id>`: The object_id of the NGINX Instance you want to update the NGINX Config for.
74
-
- `<token-value>`: Your API Token.
75
-
76
-
With `PATCH`, you can update specific parts of the NGINX Config without needing to resend the entire configuration. The following file `contents` disposition is observed:
77
-
- Leave out file `contents` to remove the file from the NGINX Config.
78
-
- Include file `contents` to add or update the file in the NGINX Config. File `contents` must be base64 encoded. File `contents` can be an empty string to create an empty file.
79
-
- `config_version` should be included to ensure you're updating the correct version of the configuration. You can get the current `config_version` from the response of the `GET` request.
80
-
81
-
For example, to update only the `/etc/nginx/nginx.conf` file in the NGINX Config, your `partial_update_config.json` might look like this:
82
-
```json
79
+
```
80
+
-`<tenant>`: Your tenant name for organization plans.
81
+
-`<namespace>`: The namespace your Instance belongs to.
82
+
-`<instance-object-id>`: The object_id of the NGINX Instance you want to update the NGINX Config for.
83
+
-`<token-value>`: Your API Token.
84
+
85
+
With `PATCH`, you can update specific parts of the NGINX Config without needing to resend the entire configuration. The following file `contents` disposition is observed:
86
+
- Leave out file `contents` to remove the file from the NGINX Config.
87
+
- Include file `contents` to add or update the file in the NGINX Config. File `contents` must be base64 encoded. File `contents` can be an empty string to create an empty file.
88
+
-`config_version` should be included to ensure you're updating the correct version of the configuration. You can get the current `config_version` from the response of the `GET` request.
89
+
90
+
For example, to update only the `/etc/nginx/nginx.conf` file in the NGINX Config, your `partial_update_config.json` might look like this:
91
+
```json
83
92
{
84
93
"conf_path": "/etc/nginx/nginx.conf",
85
94
"config_version": "<config_version from GET response>",
@@ -95,16 +104,9 @@ You can modify the NGINX Config using either `PUT` or `PATCH` requests. The `PUT
95
104
}
96
105
]
97
106
}
98
-
```
99
-
{{< call-out "note" >}}
100
-
To encode files in base64, you can use the following command in a Unix-like terminal:
101
-
```shell
102
-
base64 /path/to/your/file
103
107
```
104
-
Replace `/path/to/your/file` with the actual path to the file you want to encode.
105
-
{{< /call-out>}}
106
-
To remove a file, simply omit the `contents` field for that file in your `PATCH` request body, your `partial_update_config.json` might look like this to remove `/etc/nginx/conf.d/default.conf` from the NGINX Config:
107
-
```json
108
+
To remove a file, simply omit the `contents` field for that file in your `PATCH` request body, your `partial_update_config.json` might look like this to remove `/etc/nginx/conf.d/default.conf` from the NGINX Config:
109
+
```json
108
110
{
109
111
"conf_path": "/etc/nginx/nginx.conf",
110
112
"config_version": "<config_version from GET response>",
@@ -119,9 +121,11 @@ You can modify the NGINX Config using either `PUT` or `PATCH` requests. The `PUT
119
121
}
120
122
]
121
123
}
122
-
```
123
-
Multiple updates can be made in a single `PATCH` request. For example, to update `/etc/nginx/nginx.conf` and remove `/etc/nginx/conf.d/default.conf`, your `partial_update_config.json` might look like this:
124
-
```json
124
+
```
125
+
## Set up multiple updates with PATCH
126
+
127
+
Multiple updates can be made in a single `PATCH` request. For example, to update `/etc/nginx/nginx.conf` and remove `/etc/nginx/conf.d/default.conf`, your `partial_update_config.json` might look like this:
128
+
```json
125
129
{
126
130
"conf_path": "/etc/nginx/nginx.conf",
127
131
"config_version": "<config_version from GET response>",
@@ -145,4 +149,4 @@ You can modify the NGINX Config using either `PUT` or `PATCH` requests. The `PUT
0 commit comments