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
+53-34Lines changed: 53 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,15 @@ In this guide, we'll show you how to use API requests to update NGINX Configs fo
12
12
13
13
## Getting ready
14
14
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.
16
16
17
17
{{< 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.
19
19
{{< /call-out>}}
20
20
21
21
## Getting the current NGINX Config
22
22
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.
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
26
@@ -34,7 +34,7 @@ Use the following curl command to retrieve the current NGINX Config for a specif
34
34
-`<token-value>`: Your API Token.
35
35
36
36
{{< 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.
38
38
{{< /call-out>}}
39
39
40
40
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
77
77
- Leave out file `contents` to remove the file from the NGINX Config.
78
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
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
-
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:
81
81
```json
82
82
{
83
83
"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
+
]
91
94
}
92
-
}
95
+
]
93
96
}
94
97
```
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:
96
106
```json
97
107
{
98
108
"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
+
]
105
118
}
106
-
}
119
+
]
107
120
}
108
121
```
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:
110
123
```json
111
124
{
112
125
"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>",
0 commit comments