Hello. To assign an ASM security policy to a virtual server via the GUI I would go to Local Traffic → Virtual Servers → Virtual Server List, click on the Virtual Server, click Security → Policies, under Application Security Policy I would choose “Enable”, then choose the Policy.
How would I accomplish the same via the TMSH command? Thanks.
Consider the below naming conventions:
ASM Policy name: ASM_Policy
Virtual server name : HTTP_VS1
Below is the command:
tmsh create ltm policy asm_policy_HTTP_VS1 { controls add { asm } requires add { http } rules add { default { actions add { 1 { asm enable policy ASM_Policy } } ordinal 1 } } }
tmsh modify ltm virtual HTTP_VS1 policies add { asm_policy_HTTP_VS1 }
tmsh save sys config
Thank you Nazir. What’s the best way to accomplish the above steps using Rest? Thanks.
Get the ID of the existing ASM policy:
curl -sku admin:admin | ./jq ‘.items[] | “pol_name:” + .fullPath + “;api_id:” + .id’
Assign ASM policy with id ZsKuSt3CrOF9LBMAapLOkg to VS HTTP_VS1:
curl -sku admin:admin -X PATCH -H “Content-Type: application/json” -d ‘{ “virtualServers” : [“/Common/HTTP_VS1”] }’ | ./jq