Rewrite Rule triggers the 502 server Error

#1
Hi,

I am currently using the load balancer and LiteSpeed on the Google Cloud Platform (GCP).

The problem is whenever I rewrite rules as shown below on the Litespeed admin panel, it triggers the 502 server error.

Code:
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
However, another rewrite rules as shown below works.

Code:
RewriteCond %{HTTP_HOST} ^12\.34\.56\.78 [OR]
RewriteCond %{HTTP_HOST} ^www.example\.com$
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
Based on my research, the 502 error occurs whenever the server TCP session timeout (Keep-Alive timeout) is shorter than the default TCP session timeout of the GCP, which has 600 secs.

I understand that I can modify the Keep-Alive timeout in the LightSpeed's admin panel, but only up to 60 secs.

To fix the issue,

1) how can I adjust the Keep-Alive timeout more than 60 secs?

If my presumption is wrong,

2) Is there any other reason or solution to solve the 502 server error?

Addition: When I applied Rewrite Rules suddenly 404 Page error occurred. Deleting and Re-updating a same rewrite rule solved the issue.



Thank you
 
Last edited:

Cold-Egg

Administrator
#2
Hi,

Even if you don't apply rewrite rules, keep-alive is still enabled by default on OLS, so your presumption might be wrong.
About 404, please remove the GCP Load Balancer and check if the issue still reproducible.
 
#3
Hi,

thank you for your reply.
This is not my presumption. It is officially listed in Google cloud doc.

And I have confirmed with Google that Keep alive timeout will trigger the server drop from Load Balancer if the Keep alive timeout of the server is less than 600 secs
 
Top