Stage NGINX configs
With F5 NGINX Instance Manager, you can easily pre-configure and stage NGINX configuration files, so you can quickly publish them to individual NGINX instances or instance groups whenever you’re ready.
To complete the instructions in this guide, ensure:
- NGINX Instance Manager is installed, licensed, and running.
Interacting with the API You can use tools such ascurl
or Postman to interact with the Instance Manager REST API. The API URL follows the formathttps://<NIM_FQDN>/api/nim/<API_VERSION>
and must include authentication information with each call. For more information about authentication options, refer to the API Overview.
To stage an NGINX instance’s configuration for publication to other instances or instance groups, follow these steps:
- On the left menu, select Instances.
- On the Instances Overview page, select an instance in the list that has the configuration you want to stage.
- Select Edit Config.
- Make your desired changes to the instance’s config files. The config analyzer will let you know if there are any errors.
- To stage your changes so you can publish them later, select Save as and provide a name for the staged config.
- Select Save.
- To view the staged config, select Staged Configs on the left menu. The staged config should appear in the list.
Follow these steps to create a new staged configuration:
- On the left menu, select Staged Configs.
- Select Create.
- On the Create Config form, complete the necessary fields:
- Config name: Give the staged config a name.
- Config files root directory: Specify the root directory where configuration files can be written to and read from. The default is
/etc/nginx/
. - Aux files root directory: Specify the root directory where auxiliary files can be written to and read from. The default is
/etc/nginx/aux
.
- Select Create.
- On the Overview page, select the staged config you just created.
- Select Add File.
- Specify the file path and file name. For example,
/etc/nginx/conf.d/default.conf
. - Select Create.
- Type or paste the contents of the file in the configuration editor.
- Repeat steps 6–9 to add other files.
- Select Save when you’re done.
To update a staged configuration:
- On the left menu, select Staged Configs.
- From the list of staged configs, select one you want to update.
- Edit the staged configuration files as needed. The config analyzer will let you know if there are any errors.
- Select Save to save the configuration.
To publish a staged configuration to an NGINX instance or instance group:
- On the left menu, select Staged Configs.
- From the list of staged configs, select the one you want to publish.
- Select Publish to.
- Select the NGINX instance or instance group to publish the staged config to.
- Select Publish.
With the Instance Manager REST API, you can add a commit hash to NGINX configurations if you use version control, such as Git. This allows you to retrieve a configuration with a unique version identifier.
To add a commit hash to a new or staged config using the REST API, send an HTTP POST
or PUT
request to the Configs endpoint.
- Method:
POST
orPUT
- Endpoint:
/configs
When adding version control identifiers to a config, include the following parameters:
- externalID (optional): The commit hash, 1–150 characters. For example,
521747298a3790fde1710f3aa2d03b55020575aa
. - externalIdType (optional): The type of commit used for the config update. Possible values are
git
orother
. IfexternalID
isn’t specified, the type defaults toother
.
{
"configName": "test-staged",
"configFiles": {
"rootDir": "/etc/nginx",
"files": [
{
"contents": "base64_encoded_contents",
"name": "/etc/nginx/nginx.conf"
}
]
},
"auxFiles": {
"rootDir": "/etc/nginx/aux",
"files": []
},
"externalId": "8acf5aed9d2872b266d2f880cab23a4aa5791d1b",
"externalIdType": "git"
}
Commit information reset upon direct edits If you edit an NGINX configuration in the Instance Manager web interface or directly on the data plane, previous hashed commit information will be lost:externalID
will revert tonull
andexternalIdType
will revert toother
automatically.
To view a staged config, send an HTTP GET
request to the Configs endpoint.
- Method:
GET
- Endpoint:
/configs/{config_uid}
To view a staged config with a version-controlled hash, send an HTTP GET
request to the Configs endpoint and specify the externalID
.
- Method:
GET
- Endpoint:
/configs/{config_uid}?externalId={commit_hash}
{
"configName": "test-staged",
"configFiles": {
"rootDir": "/etc/nginx",
"files": [
{
"contents": "base64_encoded_contents",
"name": "/etc/nginx/nginx.conf"
}
]
},
"auxFiles": {
"rootDir": "/etc/nginx/aux",
"files": []
},
"externalId": "8acf5aed9d2872b266d2f880cab23a4aa5791d1b",
"externalIdType": "git"
}