Skip to content

[Bug] Reverse proxy config parse error #8442

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
asdf2adsfad opened this issue Apr 21, 2025 · 2 comments
Open

[Bug] Reverse proxy config parse error #8442

asdf2adsfad opened this issue Apr 21, 2025 · 2 comments

Comments

@asdf2adsfad
Copy link

asdf2adsfad commented Apr 21, 2025

Contact Information

No response

1Panel Version

latest

Problem Description

Create a site and then choose reverse proxy, then edit the 原文, replace with the following, then refresh page, boom you cannot see the reverse proxy config anymore yayyyyyyyyyyyyyy

https://pastebin.com/WVrcgtPH

Steps to Reproduce

as above

The expected correct result

No response

Related log output

/api/v1/websites/proxies

{
    "code": 500,
    "message": "服务内部错误: error",
    "data": null
}

ChatGPT Says

After double-checking the code, I can confirm that my analysis is correct. The bug is definitely in the GetProxies function in backend/app/service/website.go.

Let me highlight the specific problematic code more precisely:

config, err = parser.NewStringParser(string(content)).Parse()
if err != nil {
    return nil, err
}
directives := config.GetDirectives()

location, ok := directives[0].(*components.Location)
if !ok {
    err = errors.New("error")  // This is the critical line that causes the 500 error
    return
}

The issues are:

  1. The function has a strict expectation that the parsed configuration's first directive MUST be a Location directive
  2. Your complex Nginx configuration includes multiple location blocks and other directives
  3. The type assertion directives[0].(*components.Location) fails with the complex configuration
  4. The function returns a non-descriptive error message: errors.New("error")
  5. The error bubbles up through the API as a 500 response

This is a clear design limitation in the proxy parser that can't handle complex Nginx configurations with multiple location blocks and nested directives. The parser is expecting a simple structure but receives a complex one, leading to the failure.

The function lacks proper error handling for configurations that don't match its expected structure, which explains the non-specific error message you received.

@asdf2adsfad
Copy link
Author

Okay here is the minimal reproduce: add one comment in the reverse proxy source file in the first line, then boom

I think this is a product issue rather than a simple technical problem. You can't stop people from adding multiple directive into one single file. In that case, whether to split automatically, to ban user from doing that, or to automatically parse the data, remains a question. Further, the error message is also confusing, and is not helpful for debugging. Just some of my thoughts :)

@zhengkunwang223
Copy link
Member

Thank you for your feedback. Reverse proxy currently supports only one location. Handling multiple locations in a form is not possible, so we will add a prompt message in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants