tencent cloud

边缘安全加速平台 EO

动态与公告
产品动态
安全公告
产品公告
产品简介
产品概述
产品优势
应用场景
EdgeOne 与 CDN 等产品功能对比
使用限制
购买指南
试用套餐体验权益说明
免费版套餐使用说明
计费概述
计费项目
购买指引
续费指引
欠费与退款说明
套餐选型对比
关于“干净流量”计费说明
DDoS 防护容量说明
快速入门
选择业务场景
快速接入网站安全加速
通过 Pages 快速部署网站
域名服务与源站配置
域名服务
HTTPS 证书
源站配置
站点加速
概述
访问控制
智能加速
缓存配置
文件优化
网络优化
URL 重写
修改头部
修改应答内容
规则引擎
图片与视频处理
单连接下载限速
DDoS 与 Web 防护
概述
DDoS 防护
Web 防护
Bot 管理
API 资产识别(Beta)
边缘函数
概述
快速指引
操作指引
Runtime APIs
示例函数
实践教程
Pages
四层代理
概述
新建四层代理实例
修改四层代理实例配置
停用/删除四层代理实例
批量配置转发规则
获取客户端真实IP
数据分析与日志服务
日志服务
数据分析
告警服务
站点与计费管理
计费管理
站点管理
版本管理
通用策略
通用参考
配置语法
请求与响应行为
国家/地区及对应代码枚举
Terraform
Terraform 简介
安装和配置 Terraform
实践教程
EdgeOne Skill 使用指南
自动预热/清除缓存
防盗刷/盗链实践
HTTPS 相关实践
加速优化
流量调度
数据分析与告警
第三方日志平台集成实践
对象存储类源站(例如:COS)配置实践
跨域响应配置
API 文档
History
Introduction
API Category
Making API Requests
Site APIs
Acceleration Domain Management APIs
Site Acceleration Configuration APIs
Edge Function APIs
Alias Domain APIs
Security Configuration APIs
Layer 4 Application Proxy APIs
Content Management APIs
Data Analysis APIs
Log Service APIs
Billing APIs
Certificate APIs
Origin Protection APIs
Load Balancing APIs
Diagnostic Tool APIs
Custom Response Page APIs
API Security APIs
DNS Record APIs
Content Identifier APIs
Legacy APIs
Ownership APIs
Image and Video Processing APIs
Multi-Channel Security Gateway APIs
Version Management APIs
Data Types
Error Codes
常见问题
产品特性相关问题
DNS 记录相关问题
域名配置相关问题
站点加速相关问题
数据与日志相关问题
安全防护相关问题
源站配置相关问题
排障指南
异常状态码参考
EdgeOne 4XX/5XX 状态码排障指南
520/524状态码排障指南
521/522 状态码排障指南
工具指南
相关协议
Service Level Agreement
源站防护启用特别约定
TEO 政策
隐私协议
数据处理和安全协议
联系我们
词汇表

ModifySecurityPolicy

PDF
聚焦模式
字号
最后更新时间: 2025-10-30 22:02:05

1. API Description

Domain name for API request: teo.intl.tencentcloudapi.com.

This API is used to modify the web and bot security configurations.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common Params. The value used for this API: ModifySecurityPolicy.
Version Yes String Common Params. The value used for this API: 2022-09-01.
Region No String Common Params. This parameter is not required.
ZoneId Yes String Zone ID.
SecurityConfig Yes SecurityConfig Security policy configuration.
  • when ExceptionRules in the SecurityPolicy parameter is set, ExceptConfig in the SecurityConfig parameter will be ignored;
  • when CustomRules in the SecurityPolicy parameter is set, AclConfig and IpTableConfig in the SecurityConfig parameter will be ignored;
  • when HttpDDoSProtection and RateLimitingRules in the SecurityPolicy parameter are set, RateLimitConfig in the SecurityConfig parameter will be ignored;
  • when ManagedRule in the SecurityPolicy parameter is set, WafConfig in the SecurityConfig parameter will be ignored;
  • for exception rules, custom rules, rate limits, and managed rule policy, it is recommended to use the SecurityPolicy parameter for configuration.
  • .
    SecurityPolicy No SecurityPolicy Security policy configuration. recommend using for Web exception rules, protection custom policies, rate rules, and managed rules. supports configuring security policies with expression grammar.
    Entity No String SecurityPolicy type, the following parameter values can be used for query:
  • ZoneDefaultPolicy: used to specify a query for site-level policies;
  • Template: used to specify a query for policy templates. the TemplateId parameter needs to be specified simultaneously;
  • Host: used to specify a query for domain-level policies (note: when using Host to specify a domain name service policy, only domain name services or policy templates that have been applied domain-level policies are supported).
  • Host No String Specify the domain name. When the Entity parameter value is set to Host, use the domain-level policy specified by this parameter to query the domain configuration. For example, use www.example.com to configure the domain-level policy for that domain name.
    TemplateId No String Specify the policy template ID. Use this parameter to specify the ID of the policy Template to query the Template configuration when the Entity parameter value is set to Template.

    3. Output Parameters

    Parameter Name Type Description
    RequestId String The unique request ID, generated by the server, will be returned for every request (if the request fails to reach the server for other reasons, the request will not obtain a RequestId). RequestId is required for locating a problem.

    4. Example

    Example1 Modifying a Domain Name Policy

    Modify the domain policy of a.eotest.com under the eotest.com site

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ModifySecurityPolicy
    <Common request parameters>
    
    {
        "ZoneId": "zone-fa89j239a",
        "Entity": "Host",
        "Host": "a.eotest.com",
        "SecurityConfig": {},
        "SecurityPolicy": {
            "ExceptionRules": {
                "Rules": [
                    {
                        "Id": "1492837231",
                        "Name": "ExampleSkipModule",
                        "Condition": "${http.request.uri.path} in ['/api/v3/test','/api/v3/submit'] and ${http.request.method} in ['POST']",
                        "SkipScope": "WebSecurityModules",
                        "WebSecurityModulesForException": [
                            "websec-mod-custom-rules",
                            "websec-mod-rate-limiting"
                        ],
                        "Enabled": "On"
                    },
                    {
                        "Id": "1492837231",
                        "Name": "SampleSkipManagedRule",
                        "Condition": "${http.request.uri.path} in ['/api/v3/test','/api/v3/submit'] and ${http.request.method} in ['POST']",
                        "SkipScope": "ManagedRules",
                        "SkipOption": "SkipOnAllRequestFields",
                        "ManagedRulesForException": [
                            "4401215074",
                            "4368124487"
                        ],
                        "Enabled": "On"
                    },
                    {
                        "Id": "1492837231",
                        "Name": "SampleSkipManagedRule",
                        "Condition": "${http.request.uri.path} in ['/api/v3/test','/api/v3/submit'] and ${http.request.method} in ['POST']",
                        "SkipScope": "ManagedRules",
                        "SkipOption": "SkipOnAllRequestFields",
                        "ManagedRuleGroupsForException": [
                            "wafgroup-sql-injection-attacks"
                        ],
                        "Enabled": "On"
                    },
                    {
                        "Id": "1492837231",
                        "Name": "SampleSkipManagedRuleForField",
                        "Condition": "${http.request.uri.path} in ['/api/v3/test','/api/v3/submit'] and ${http.request.method} in ['POST']",
                        "SkipScope": "ManagedRules",
                        "ManagedRulesForException": [
                            "4401215074",
                            "4368124487"
                        ],
                        "SkipOption": "SkipOnSpecifiedRequestFields",
                        "RequestFieldsForException": [
                            {
                                "Scope": "cookie",
                                "Condition": "",
                                "TargetField": "key"
                            },
                            {
                                "Scope": "cookie",
                                "Condition": "${key} in ['session-id']",
                                "TargetField": "value"
                            },
                            {
                                "Scope": "cookie",
                                "Condition": "${key} in ['account-id'] and ${value} like ['prefix-*']",
                                "TargetField": "value"
                            },
                            {
                                "Scope": "header",
                                "Condition": "",
                                "TargetField": "key"
                            },
                            {
                                "Scope": "header",
                                "Condition": "${key} in ['x-trace-id']",
                                "TargetField": "value"
                            },
                            {
                                "Scope": "header",
                                "Condition": "${key} like ['x-auth-*'] and ${value} like ['Bearer *']",
                                "TargetField": "value"
                            },
                            {
                                "Scope": "uri.query",
                                "Condition": "",
                                "TargetField": "key"
                            },
                            {
                                "Scope": "uri.query",
                                "Condition": "${key} in ['action']",
                                "TargetField": "value"
                            },
                            {
                                "Scope": "uri.query",
                                "Condition": "${key} in ['action'] and ${value} in ['upload', 'delete']",
                                "TargetField": "value"
                            },
                            {
                                "Scope": "uri",
                                "Condition": "",
                                "TargetField": "query"
                            },
                            {
                                "Scope": "uri",
                                "Condition": "",
                                "TargetField": "path"
                            },
                            {
                                "Scope": "uri",
                                "Condition": "",
                                "TargetField": "fullpath"
                            },
                            {
                                "Scope": "body.json",
                                "Condition": "",
                                "TargetField": "key"
                            },
                            {
                                "Scope": "body.json",
                                "Condition": "${key} in ['user.id']",
                                "TargetField": "value"
                            },
                            {
                                "Scope": "body.json",
                                "Condition": "${key} in ['user.id'] and ${value} in ['1234', '5678']",
                                "TargetField": "value"
                            },
                            {
                                "Scope": "body",
                                "Condition": "",
                                "TargetField": "fullbody"
                            },
                            {
                                "Scope": "body",
                                "Condition": "",
                                "TargetField": "multipart"
                            }
                        ],
                        "Enabled": "On"
                    }
                ]
            },
            "CustomRules": {
                "Rules": [
                    {
                        "Id": "1492837231",
                        "Name": "SampleBasicACLRule",
                        "Condition": "${http.request.ip} in ['1.1.1.1', '10.10.10.0/24', ${security.ip_group['123'@'zone-2xsnpvkhdjes']} ]",
                        "Action": {
                            "Name": "Deny"
                        },
                        "Priority": 10,
                        "Enabled": "on"
                    }
                ]
            },
            "HttpDDoSProtection": {
                "AdaptiveFrequencyControl": {
                    "Enabled": "on",
                    "Sensitivity": "Loose",
                    "Action": {
                        "Name": "Monitor"
                    }
                },
                "ClientFiltering": {
                    "Enabled": "on",
                    "Action": {
                        "Name": "Monitor"
                    }
                },
                "BandwidthAbuseDefense": {
                    "Enabled": "on",
                    "Action": {
                        "Name": "Monitor"
                    }
                },
                "SlowAttackDefense": {
                    "Enabled": "on",
                    "Action": {
                        "Name": "Monitor"
                    },
                    "MinimalRequestBodyTransferRate": {
                        "Enabled": "on",
                        "MinimalAvgTransferRateThreshold": "50bps",
                        "CountingPeriod": "60s"
                    },
                    "RequestBodyTransferTimeout": {
                        "Enabled": "on",
                        "IdleTimeout": "5s"
                    }
                }
            },
            "RateLimitingRules": {
                "Rules": [
                    {
                        "Enabled": "on",
                        "Name": "SampleHttpDdosRule",
                        "Condition": "${http.request.uri.path} in ['/api/v3/test','/api/v3/submit']",
                        "CountBy": [
                            "http.request.ip",
                            "http.request.cookies['UserSession']"
                        ],
                        "MaxRequestThreshold": 1000,
                        "CountingPeriod": "2m",
                        "ActionDuration": "20h",
                        "Action": {
                            "Name": "ManagedChallenge"
                        },
                        "Id": "2181399690",
                        "Priority": 100
                    }
                ]
            },
            "ManagedRules": {
                "Enabled": "on",
                "AutoUpdate": {
                    "AutoUpdateToLatestVersion": "off",
                    "RulesetVersion": "2023-12-21T12:00:32Z"
                },
                "SemanticAnalysis": "on",
                "DetectionOnly": "on",
                "ManagedRuleGroups": [
                    {
                        "GroupId": "wafmanagedrulegroup-vulnerability-scanners",
                        "SensitivityLevel": "wafmanagedrule-sensitivity-level-extreme",
                        "Action": {
                            "Name": "Monitor"
                        }
                    }
                ]
            }
        }
    }

    Output Example

    {
        "Response": {
            "RequestId": "08b32010-ab25-42a4-b923-777c481da684"
        }
    }

    Example2 Modifying Template Policy

    Modify the policy of the temp-00iel413 template under the eotest.com site

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ModifySecurityPolicy
    <Common request parameters>
    
    {
        "ZoneId": "zone-fa89j239a",
        "Entity": "Template",
        "TemplateId": "temp-00iel413",
        "SecurityConfig": {},
        "SecurityPolicy": {
            "CustomRules": {
                "Rules": [
                    {
                        "Id": "1492837231",
                        "Name": "SampleBasicACLRule",
                        "Condition": "${http.request.ip} in ['1.1.1.1', '10.10.10.0/24', ${security.ip_group['123'@'zone-2xsnpvkhdjes']} ]",
                        "Action": {
                            "Name": "Deny"
                        },
                        "Priority": 10,
                        "Enabled": "on"
                    }
                ]
            }
        }
    }

    Output Example

    {
        "Response": {
            "RequestId": "08b32010-ab25-42a4-b923-777c481da684"
        }
    }

    Example3 Modifying a Site-Level Policy

    This example shows you how to modify the site-level policy for eotest.com.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ModifySecurityPolicy
    <Common request parameters>
    
    {
        "ZoneId": "zone-fa89j239a",
        "Entity": "ZoneDefaultPolicy",
        "SecurityConfig": {},
        "SecurityPolicy": {
            "ManagedRules": {
                "Enabled": "on",
                "AutoUpdate": {
                    "AutoUpdateToLatestVersion": "off",
                    "RulesetVersion": "2023-12-21T12:00:32Z"
                },
                "SemanticAnalysis": "on",
                "DetectionOnly": "on",
                "ManagedRuleGroups": [
                    {
                        "GroupId": "wafmanagedrulegroup-vulnerability-scanners",
                        "SensitivityLevel": "wafmanagedrule-sensitivity-level-extreme",
                        "Action": {
                            "Name": "Monitor"
                        }
                    }
                ]
            }
        }
    }

    Output Example

    {
        "Response": {
            "RequestId": "08b32010-ab25-42a4-b923-777c481da684"
        }
    }

    Example4 Modifying Security Configuration

    This example shows you how to modify the layer-7 security configuration for the domain a.eotest.com.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ModifySecurityPolicy
    <Common request parameters>
    
    {
        "ZoneId": "zone-fa89j239a",
        "Entity": "a.eotest.com",
        "SecurityConfig": {
            "WafConfig": {
                "Switch": "on",
                "WafRule": {
                    "Switch": "on",
                    "ObserveRuleIDs": [],
                    "BlockRuleIDs": [
                        162502146
                    ]
                },
                "Mode": "block",
                "Level": "loose"
            }
        }
    }

    Output Example

    {
        "Response": {
            "RequestId": "08b32010-ab25-42a4-b923-2e6c481dae23"
        }
    }

    Example5 Modifying an Exception Rule to Allow Specified Fields

    This example shows you how to use the following configuration to skip WAF security protection by whitelisting certain fields (such as all keys in the HTTP Header) for a specific scenario (for example, HTTP requests with the path /skipwaf) in WAF protection.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ModifySecurityPolicy
    <Common request parameters>
    
    {
        "ZoneId": "zone-fa89j239a",
        "Entity": "*.eotest.com",
        "SecurityConfig": {
            "ExceptConfig": {
                "Switch": "on",
                "ExceptUserRules": [
                    {
                        "Action": "skip",
                        "ExceptUserRuleConditions": [
                            {
                                "MatchContent": "/skipwaf",
                                "MatchFrom": "cgi",
                                "Operator": "equal"
                            }
                        ],
                        "ExceptUserRuleScope": {
                            "Type": "partial",
                            "PartialModules": [
                                {
                                    "Module": "waf",
                                    "Include": [
                                        106247778
                                    ]
                                }
                            ],
                            "SkipConditions": [
                                {
                                    "MatchContent": [],
                                    "MatchFrom": [],
                                    "Selector": "keys",
                                    "Type": "header_fields"
                                }
                            ]
                        },
                        "RuleID": 0,
                        "RuleName": "first_webshell",
                        "RulePriority": 0,
                        "RuleStatus": "on",
                        "UpdateTime": "2022-09-22T03:00:10Z"
                    }
                ]
            }
        }
    }

    Output Example

    {
        "Response": {
            "RequestId": "08b32010-ab25-42a4-b923-2e6c481dae44"
        }
    }

    Example6 Modifying Exception Rules in Security Configuration and Whitelisting Header key Field Scenarios

    In WAF security protection, if a certain scenario exists in the business (such as an http request with the path /skipwaf) where partial fields (such as the Value corresponding to YourSkipHeader in the HTTP Header) need to be whitelisted to skip WAF security protection, you can use the following configuration.

    Input Example

    POST / HTTP/1.1
    Host: teo.intl.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: ModifySecurityPolicy
    <Common request parameters>
    
    {
        "ZoneId": "zone-fa89j239a",
        "Entity": "*.eotest.com",
        "SecurityConfig": {
            "ExceptConfig": {
                "Switch": "on",
                "ExceptUserRules": [
                    {
                        "Action": "skip",
                        "ExceptUserRuleConditions": [
                            {
                                "MatchContent": "/skipwaf",
                                "MatchFrom": "cgi",
                                "Operator": "equal"
                            }
                        ],
                        "ExceptUserRuleScope": {
                            "Type": "partial",
                            "PartialModules": [
                                {
                                    "Module": "waf",
                                    "Include": [
                                        106247778
                                    ]
                                }
                            ],
                            "SkipConditions": [
                                {
                                    "MatchContent": [],
                                    "MatchFrom": [
                                        "YourSkipHeader"
                                    ],
                                    "MatchFromType": "equal",
                                    "Selector": "values",
                                    "Type": "header_fields"
                                }
                            ]
                        },
                        "RuleID": 0,
                        "RuleName": "first_webshell",
                        "RulePriority": 0,
                        "RuleStatus": "on",
                        "UpdateTime": "2022-09-22T03:00:10Z"
                    }
                ]
            }
        }
    }

    Output Example

    {
        "Response": {
            "RequestId": "08b32010-ab25-42a4-b923-2e6c481dae66"
        }
    }

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    InternalError.ConfigLocked The configuration is locked. Please unlock and try again.
    InternalError.ProxyServer An unknown error occurred in the backend server.
    InternalError.RouteError The backend routing address is incorrect.
    InvalidParameter.Security Invalid parameter.
    LimitExceeded.Security Limit exceeded
    OperationDenied Operation denied.
    ResourceInUse The resource is occupied.
    UnauthorizedOperation.CamUnauthorized CAM is not authorized.
    UnauthorizedOperation.NoPermission The sub-account is not authorized for the operation. Please get permissions first.
    UnauthorizedOperation.Unknown An unknown error occurred in the backend server.
    UnsupportedOperation Unsupported operation.

    帮助和支持

    本页内容是否解决了您的问题?

    填写满意度调查问卷,共创更好文档体验。

    文档反馈