Skip to content

Commit 271644e

Browse files
committed
Update nginx_configuration.md
1 parent 6e612b6 commit 271644e

File tree

1 file changed

+52
-48
lines changed

1 file changed

+52
-48
lines changed

content/nginx-one/api/nginx_configuration.md

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ The workflows for managing NGINX Configs for Instances, Config Sync Groups, and
2323
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.
2424

2525
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-
2726
```shell
2827
curl -X GET "https://<tenant>.console.ves.volterra.io/api/nginx/one/namespaces/<namespace>/instances/<instance-object-id>/config" \
2928
-H "Authorization: APIToken <token-value>" -o current_config.json
@@ -39,47 +38,57 @@ To update the NGINX Config for a Config Sync Group or Staged Config, replace `in
3938

4039
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.
4140

42-
## Updating the NGINX Config
43-
4441
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.
4542

46-
1. **Update the NGINX Config for an Instance using `PUT`**:
43+
## How to base64 encode a file for JSON request
4744

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 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.
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.
74+
```shell
6675
curl -X PATCH "https://<tenant>.console.ves.volterra.io/api/nginx/one/namespaces/<namespace>/instances/<instance-object-id>/config" \
6776
-H "Authorization : APIToken <token-value>" \
6877
-H "Content-Type: application/json" \
6978
-d @partial_update_config.json
70-
```
71-
- `<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
8392
{
8493
"conf_path": "/etc/nginx/nginx.conf",
8594
"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
95104
}
96105
]
97106
}
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
103107
```
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
108110
{
109111
"conf_path": "/etc/nginx/nginx.conf",
110112
"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
119121
}
120122
]
121123
}
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
125129
{
126130
"conf_path": "/etc/nginx/nginx.conf",
127131
"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
145149
}
146150
]
147151
}
148-
```
152+
```

0 commit comments

Comments
 (0)