fix: Enhance OperateProxy location parsing to support custom Nginx configs #9901
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it?
In practical use, reverse proxy configurations may be customized, which can lead to errors when modifying or reading them through the web interface. Previously, the system strictly required the first line to be a location block and allowed only one location block per configuration file. If these conditions were not met, both the modification and reading interfaces would return errors, and recovery through the UI was impossible—manual edits to the reverse proxy configuration were required.
之前的 pr 只给读取改了判断逻辑,遗漏了修改接口的判断,遂补充。
在实际使用中,反向代理配置有可能会发生自定义更改,导致通过网页的更改和读取报错。之前必须严格遵从第一行为 location 块头并且配置文件只能存在一个 location 的情况。如果不遵守该格式,由于强制转换原因,读取接口会返回 error错误并且无法从面板恢复,只能手工更改反向代理配置文件解决。
Summary of your change
This PR updates the logic for parsing the location block in reverse proxy configurations (modification and reading interfaces—the reading interface was submitted in a previous PR, this one completes the modification part that was missing). Now, only the first location block in the configuration file is read and affected when editing via the web panel. This change prevents issues where custom configurations or misoperations cause the web panel to fail in reading the reverse proxy settings for a site.
修改反向代理配置的 location 解析逻辑(修改和读取接口,读取接口在上个 pr 已提交,修改接口为补充遗漏)。目前只会读取一个反向代理文件中第一个 符合 location 的块,并且如果用户通过面板修改反向代理,也只会对第一个 location 生效。避免产生难恢复的 error 错误。
Please indicate you've done the following: