Bug: Version Apisix3.9 ,dashboard Version 3.0.1,The Console Displays An Exception.

by ADMIN 83 views

Introduction

APISIX is a high-performance API gateway that provides a flexible and scalable solution for managing APIs. However, like any complex system, it is not immune to bugs and issues. In this article, we will explore a specific bug that occurs when using the proxy-rewrite plugin in APISIX version 3.9, along with the APISIX Dashboard version 3.0.1. We will examine the current behavior, expected behavior, error logs, and steps to reproduce the issue.

Current Behavior

According to the official APISIX documentation, when using the header.add interface to add headers, it will display the added headers in the console. However, in this specific case, when using the proxy-rewrite plugin to add headers, the console displays an exception.

To reproduce this issue, we need to use the following call interface parameters:

{
    "uri": "/111111*",
    "upstream_id": "web",
    "hosts": [
        "abc12.com"
    ],
    "name": "111111",
    "desc": "1111111n",
    "plugins": {
        "response-rewrite": {
            "headers": {
                "Cache-Control": "$cache"
            }
        },
        "proxy-rewrite": {
            "headers": {
                "add": {
                    "Host": "$host",
                    "X-Real-IP": "$remote_addr",
                    "X-Forwarded-For": "$proxy_add_x_forwarded_for"
                }
            }
        }
    },
    "timeout": {
        "connect": 3,
        "send": 3,
        "read": 3
    }
}

As shown in the code snippet above, we are using the proxy-rewrite plugin to add three headers: Host, X-Real-IP, and X-Forwarded-For. However, when we run this configuration, the console displays an exception.

Expected Behavior

The expected behavior is that the added headers will be displayed in the console without any exceptions.

Error Logs

Unfortunately, there are no error logs provided in the official documentation for this specific issue. However, based on the exception displayed in the console, it is likely that the error is related to the proxy-rewrite plugin.

Steps to Reproduce

To reproduce this issue, follow these steps:

  1. Install APISIX version 3.9 and APISIX Dashboard version 3.0.1.
  2. Create a new configuration file with the following content:
{
    "uri": "/111111*",
    "upstream_id": "web",
    "hosts": [
        "abc12.com"
    ],
    "name": "111111",
    "desc": "1111111n",
    "plugins": {
        "response-rewrite": {
            "headers": {
                "Cache-Control": "$cache"
            }
        },
        "proxy-rewrite": {
            "headers": {
                "add": {
                    "Host": "$host",
                    "X-Real-IP": "$remote_addr",
                    "X-Forwarded-For": "$proxy_add_x_forwarded_for"
                }
            }
        }
    },
    "timeout": {
        "connect": 3,
        "send": 3,
        "read": 3
    }
}
  1. Run the configuration file using the APISIX command-line interface.
  2. Observe the console output and note the exception displayed.

Environment

To troubleshoot this issue, it is essential to provide the following environment information:

  • APISIX version (run apisix version):
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

By providing this information, we can better understand the environment in which the issue occurs and provide a more accurate solution.

Conclusion

Q: What is the bug in APISIX 3.9, Dashboard Version 3.0.1?

A: The bug occurs when using the proxy-rewrite plugin to add headers. The console displays an exception, and there are no error logs provided in the official documentation.

Q: What is the expected behavior when using the proxy-rewrite plugin?

A: The expected behavior is that the added headers will be displayed in the console without any exceptions.

Q: What are the steps to reproduce the bug?

A: To reproduce the bug, follow these steps:

  1. Install APISIX version 3.9 and APISIX Dashboard version 3.0.1.
  2. Create a new configuration file with the following content:
{
    "uri": "/111111*",
    "upstream_id": "web",
    "hosts": [
        "abc12.com"
    ],
    "name": "111111",
    "desc": "1111111n",
    "plugins": {
        "response-rewrite": {
            "headers": {
                "Cache-Control": "$cache"
            }
        },
        "proxy-rewrite": {
            "headers": {
                "add": {
                    "Host": "$host",
                    "X-Real-IP": "$remote_addr",
                    "X-Forwarded-For": "$proxy_add_x_forwarded_for"
                }
            }
        }
    },
    "timeout": {
        "connect": 3,
        "send": 3,
        "read": 3
    }
}
  1. Run the configuration file using the APISIX command-line interface.
  2. Observe the console output and note the exception displayed.

Q: What environment information is required to troubleshoot the bug?

A: To troubleshoot the bug, provide the following environment information:

  • APISIX version (run apisix version):
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

Q: How can I fix the bug?

A: Unfortunately, there is no known fix for this bug at this time. However, you can try the following:

  1. Update to the latest version of APISIX and APISIX Dashboard.
  2. Check the official documentation for any known issues or workarounds.
  3. Reach out to the APISIX community or support team for further assistance.

Q: Can I use a workaround to avoid the bug?

A: Yes, you can use a workaround to avoid the bug. One possible workaround is to use the header.add interface instead of the proxy-rewrite plugin to add headers.

Q: What are the implications of this bug?

A: The implications of this bug are that it can cause issues with header manipulation in APISIX. This can lead to problems with API requests and responses, which can impact the overall performance and reliability of your API gateway.

Q: How can I prevent this bug from occurring in the future?

A: To prevent this bug from occurring in the future, make sure to:

  1. Keep your APISIX and APISIX Dashboard versions up to date.
  2. Regularly check the official documentation for any known issues or workarounds.
  3. Reach out to the APISIX community or support team for further assistance.

By following these steps and providing the necessary environment information, you can help troubleshoot and fix the bug in APISIX 3.9, Dashboard Version 3.0.1.