网站返回502曾经放在负载平衡器后面

发布于 2025-01-20 14:22:03 字数 1341 浏览 4 评论 0原文

我有这个网站可行,但是一旦将其放在负载平衡器后面,就会出现502个错误。经过一些故障排除后,此片段是罪魁祸首。

    if( function_exists( 'is_shop' ) && is_shop( ) ){
        // $redirect_page_id = 132; // adjust to ID of page you are redirecting to */
        wp_redirect( '/product-category/main-dish/' , 301 ); exit;
    }
}
add_action( 'template_redirect', 'shop_redirect' );

我希望商店页面(也是主页)成为一个特定的产品档案页面。因此,我进行了重定向。以上片段工作正常,但是一旦我添加了负载平衡器,它就无法正常工作。它返回502错误。我不明白为什么它停止在负载平衡器后面工作。

负载均衡器的错误是statusDetails:“ Failed_to_to_pick_backend”

我试图将产品存档页面作为主页。我尝试使用的方法是让主页domain.com重定向到domain.com/product-category/main-dish/

我尝试了许多不同的方法来配置负载平衡器并丢失它们。这是当前的设置,我尝试启用和禁用代码段。

只是一个回顾:

  1. 该网站与启用重定向段的正确配合。
  2. 但是,一旦将其放置在负载平衡器后面,它就会产生502错误
  3. 没有502错误
  4. ,使用负载平衡器,当启用重定向片段时禁用重定向片段时,

,它会产生502。

”在此处输入图像说明”

I have this website that works but once it is placed behind a load balancer, it gives a 502 error. After some troubleshooting, this snippet is the culprit.

    if( function_exists( 'is_shop' ) && is_shop( ) ){
        // $redirect_page_id = 132; // adjust to ID of page you are redirecting to */
        wp_redirect( '/product-category/main-dish/' , 301 ); exit;
    }
}
add_action( 'template_redirect', 'shop_redirect' );

I want the shop page, which is also the home page, to be a specific product archive page. Hence, I do a redirection. The above snippet works fine but once I added a load balancer, it fails to work. It returns a 502 error. I don't understand why it stops working behind a load balancer.

The error from load balancer is statusDetails: "failed_to_pick_backend"

What I am trying to is to have the product archive page to be the home page. The approach I attempted is to have the home page domain.com to redirect to domain.com/product-category/main-dish/

I've tried many different ways to configure the load balancer and lost track of them. This is the current setting and I've tried with enabling and disabling the code snippet.

Just a recap:

  1. The website works correctly with the redirection snippet enabled.
  2. However, once it is placed behind a load balancer, it produces 502 error
  3. With a load balancer, there is no 502 error when the redirection snippet is disabled
  4. When the redirection snippet is enabled, it produces 502.

enter image description here

enter image description here

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸵鸟症 2025-01-27 14:22:03

检查您在创建负载均衡器时创建的运行状况检查,如果运行状况检查显示不健康状态,则添加运行状况检查防火墙规则,即使实例工作正常。

Check the health check you created while creating load balancer , add health check firewall rule if health check is showing unhealthy status even though instance is working fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文