网站返回502曾经放在负载平衡器后面
我有这个网站可行,但是一旦将其放在负载平衡器后面,就会出现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/
我尝试了许多不同的方法来配置负载平衡器并丢失它们。这是当前的设置,我尝试启用和禁用代码段。
只是一个回顾:
- 该网站与启用重定向段的正确配合。
- 但是,一旦将其放置在负载平衡器后面,它就会产生502错误
- 没有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:
- The website works correctly with the redirection snippet enabled.
- However, once it is placed behind a load balancer, it produces 502 error
- With a load balancer, there is no 502 error when the redirection snippet is disabled
- When the redirection snippet is enabled, it produces 502.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查您在创建负载均衡器时创建的运行状况检查,如果运行状况检查显示不健康状态,则添加运行状况检查防火墙规则,即使实例工作正常。
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.