on
03-Apr-2018
04:00
- edited on
05-Jun-2023
22:03
by
JimmyPackets
Request
PATCH https://{{big_ip_a_mgmt}}/mgmt/tm/asm/policies/{{asm_policy_hash}}
Headers
Content-Type: application/json X-F5-Auth-Token: {{big_ip_a_auth_token}}
Body
{ "virtualServers":["/Common/hackazon_vs"] }
Get more information here: Lab 3.4: Apply ASM Policy to VS — F5 Programmability Training documentation
If not careful, a problem with this procedure appears when more than one virtual uses the same policy. You must post the list of virtual names in the body of the PATCH request. If any of the virtuals already listed under the policy is not resubmitted, the policy would be be dropped from to the virtual.
This alternate method applies the policy to one vritual server at a time.
POST /mgmt/tm/ltm/policy
{ "name": "<name_for_LTM_L7_policy>", "partition": "/Common/Drafts/", "controls": [ "asm" ], "requires": [ "http" ], "status": "legacy", "strategy": "/Common/first-match", "rules" : [ { "name": "default", "fullPath": "default", "ordinal": 1, "actions" : [ { "name": "1", "fullPath": "1", "asm": true, "code": 0, "enable": true, "expirySecs": 0, "length": 0, "offset": 0, "policy": "<name_for_ASM_policy>", "port": 0, "request": true, "status": 0, "timeout": 0, "vlanId": 0 }]}] }
POST /mgmt/tm/ltm/policy
{command: "publish", name: "/Common/Drafts/<name_for_LTM_L7_policy>"}
POST /mgmt/tm/ltm/virtual/~Common~<virtual_server_name>/profiles
{ "context": "all", "name": "websecurity" }
POST /mgmt/tm/ltm/virtual/~Common~<virtual_server_name>/policies
{ "name": "<name_for_LTM_L7_policy>" }