Skip to content

Commit eaf53bf

Browse files
committed
Update nginx_configuration.md
1 parent 388bd08 commit eaf53bf

File tree

1 file changed

+53
-34
lines changed

1 file changed

+53
-34
lines changed

content/nginx-one/api/nginx_configuration.md

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ In this guide, we'll show you how to use API requests to update NGINX Configs fo
1212

1313
## Getting ready
1414

15-
Before you begin, make sure you can properly authenticate your API requests with either an API Token or API Certificate, following the instructions in the [Authentication]({{<ref "/nginx-one/api/authentication.md" >}}) guide. Ensure you have registered or created your NGINX Instance or Config Sync Group in the F5 NGINX One Console, follow the instructions in the [Manage your NGINX instances]({{<ref "/nginx-one/nginx-configs/" >}}) guide.
15+
Before you begin, make sure you can properly authenticate your API requests with either an API Token or API Certificate, following the instructions in the [Authentication]({{<ref "/nginx-one/api/authentication.md" >}}) guide. Ensure you have registered or created your NGINX Instance, Config Sync Group, or Staged Config in the F5 NGINX One Console, follow the instructions in the [Manage your NGINX instances]({{<ref "/nginx-one/nginx-configs/" >}}) guide.
1616

1717
{{< call-out "note" >}}
18-
The workflows for managing NGINX Configs for Instances and Config Sync Groups in the F5 NGINX One Console are quite similar. This guide focuses on the steps for updating NGINX Configs for Instances. If you're working with Config Sync Groups, you'll follow a similar process but will need to update the API endpoints appropriately.
18+
The workflows for managing NGINX Configs for Instances, Config Sync Groups, and Staged Configs in the F5 NGINX One Console are quite similar. This guide focuses on the steps for updating NGINX Configs for Instances. If you're working with Config Sync Groups, you'll follow a similar process but will need to update the API endpoints appropriately.
1919
{{< /call-out>}}
2020

2121
## Getting the current NGINX Config
2222

23-
You can retrieve the current NGINX Config for an Instance or Config Sync Group using a `GET` request. This is useful for making updates based on the existing configuration.
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.
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.
2626

@@ -34,7 +34,7 @@ Use the following curl command to retrieve the current NGINX Config for a specif
3434
- `<token-value>`: Your API Token.
3535

3636
{{< call-out "note" >}}
37-
To update the NGINX Config for a Config Sync Group, replace `instances` with `config-sync-groups` and use the object_id of the Config Sync Group in the URL.
37+
To update the NGINX Config for a Config Sync Group, replace `instances` with `config-sync-groups` or `staged-configs` and use the object_id of the Config Sync Group or Staged Config in the URL.
3838
{{< /call-out>}}
3939

4040
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.
@@ -77,52 +77,71 @@ You can modify the NGINX Config using either `PUT` or `PATCH` requests. The `PUT
7777
- Leave out file `contents` to remove the file from the NGINX Config.
7878
- 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.
7979
- `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-
For example, to update only the `nginx.conf` file in the NGINX Config, your `partial_update_config.json` might look like this:
80+
For example, to update only the `/etc/nginx/nginx.conf` file in the NGINX Config, your `partial_update_config.json` might look like this:
8181
```json
8282
{
8383
"conf_path": "/etc/nginx/nginx.conf",
84-
"config_version": "<config version from GET response>",
85-
"configs": {
86-
"/etc/nginx": {
87-
"files": [{
88-
"path": "nginx.conf",
89-
"contents": "<base64-encoded-content-here>"
90-
}]
84+
"config_version": "<config_version from GET response>",
85+
"configs": [
86+
{
87+
"name": "/etc/nginx",
88+
"files": [
89+
{
90+
"name": "nginx.conf",
91+
"contents": "<base64-encoded-content-here>"
92+
}
93+
]
9194
}
92-
}
95+
]
9396
}
9497
```
95-
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:
98+
{{< call-out "note" >}}
99+
To encode files in base64, you can use the following command in a Unix-like terminal:
100+
```shell
101+
base64 /path/to/your/file
102+
```
103+
Replace `/path/to/your/file` with the actual path to the file you want to encode.
104+
{{< /call-out>}}
105+
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:
96106
```json
97107
{
98108
"conf_path": "/etc/nginx/nginx.conf",
99-
"config_version": "<config version from GET response>",
100-
"configs": {
101-
"/etc/nginx/conf.d": {
102-
"files": [{
103-
"path": "default.conf"
104-
}]
109+
"config_version": "<config_version from GET response>",
110+
"configs": [
111+
{
112+
"name": "/etc/nginx/conf.d",
113+
"files": [
114+
{
115+
"name": "default.conf"
116+
}
117+
]
105118
}
106-
}
119+
]
107120
}
108121
```
109-
Multiple updates can be made in a single `PATCH` request. For example, to update `nginx.conf` and remove `default.conf`, your `partial_update_config.json` might look like this:
122+
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:
110123
```json
111124
{
112125
"conf_path": "/etc/nginx/nginx.conf",
113-
"config_version": "<config version from GET response>",
114-
"configs": {
115-
"/etc/nginx": {
116-
"files": [{
117-
"path": "nginx.conf",
118-
"contents": "<base64-encoded-content-here>"
119-
}]
126+
"config_version": "<config_version from GET response>",
127+
"configs": [
128+
{
129+
"name": "/etc/nginx/conf.d",
130+
"files": [
131+
{
132+
"name": "default.conf"
133+
}
134+
]
120135
},
121-
"/etc/nginx/conf.d": {
122-
"files": [{
123-
"path": "default.conf"
124-
}]
136+
{
137+
"name": "/etc/nginx",
138+
"files": [
139+
{
140+
"name": "nginx.conf",
141+
"contents": "<base64-encoded-content-here>"
142+
}
143+
]
125144
}
126-
}
145+
]
127146
}
128147
```

0 commit comments

Comments
 (0)