Introduction
Administrators often need to automate the creation and updating of system proxy settings (e.g., for routing external traffic) to maintain Infrastructure as Code standards, rather than relying on manual UI updates. System proxies, among other configurations, are managed globally through the System Configuration API.
This article will guide you through the process of updating system proxy configurations via System Configuration API or Terradorm.
Note: This configuration is not supported in Artifactory SaaS instances.
Method 1: Managing Proxies via REST API (cURL)
To update proxies using the API, it is required to fetch the entire global configuration, insert or modify the proxy details in the <proxies> block, and push the entire configuration back to the server.
Step 1: Fetch the current configuration
Use the following cURL command to download your current system configuration to a local file named config.xml:
curl -H "Authorization: Bearer YOUR_TOKEN" -X GET "https://<YOUR_DOMAIN>/artifactory/api/system/configuration" > config.xml
Step 2: Modify the XML file
Open the downloaded config.xml file. Locate the <proxies> block and insert or modify your proxy details.
Note on Passwords: You can safely provide the <password> value in plain text. When you post the updated configuration, Artifactory will automatically encrypt the plain-text password in the backend upon saving. An example of what a proxy block looks like:
<proxy>
<key>edenb_proxy</key>
<host>your.proxy.host</host>
<port>8083</port>
<username>new_user</username>
<password>password123</password>
<platformDefault>true</platformDefault>
<redirectedToHosts>localhost</redirectedToHosts>
</proxy>-
When preparing to upload the changes, it is required to upload the complete config.xml file with the updated proxy block. Do not upload an XML file containing only the proxy snippet, as this will overwrite and corrupt your global Artifactory configuration.
Step 3: Upload the modified configuration
Once the full XML file is updated and saved, push it back to Artifactory:
curl -H "Authorization: Bearer YOUR_TOKEN" -H "Content-Type: application/xml" -X POST "https://<YOUR_DOMAIN>/artifactory/api/system/configuration" -T config.xml
After updating the configuration, it is also possible to verify the change by referring to Administration -> Proxies:
Method 2: Infrastructure as Code (Terraform)
Another approach is to use the official JFrog Artifactory Terraform Provider, which has the Artifactory Proxy Resource.
To add the proxy, it is possible to use the artifactory_proxy resource to manage the configuration cleanly:
Terraform
resource "artifactory_proxy" "my-proxy" {
key = "edenb_proxy"
host = "your.proxy.host"
port = 8083
username = "new_user"
password = "password123"
platform_default = true
redirect_to_hosts = ["localhost"]
}
Conclusion
By using the System Configuration API or the official Terraform Provider, you can fully automate the deployment of Artifactory system proxies without relying on manual UI changes.
For further details, please review the System Configuration API documentation and the Terraform Registry artifactory_proxy documentation.