Is there a way that I can add to an Nginx config something that would at random cause 504 Gateway Timeout errors?
My current Nginx development config is:
http {
client_max_body_size 100M;
client_body_timeout 60s;
client_header_timeout 60s;
keepalive_timeout 60s;
upstream app {
server app-1:8080;
server app-2:8080;
}
server {
listen 80;
location / {
# want to enter something like
# if (random() < 10) {
# return 504;
# }
proxy_pass http://app;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded_Proto $scheme;
client_max_body_size 100M;
}
}
}
My problem is that in production I get the occasional 504 Gateway Timeout errors between Nginx and my Kotlin Spring Boot web app and I want to test running code in development to handle these errors when they come up. But in my development mode with Nginx running in a docker container, it's just working and I haven't run into the 504 Gateway errors.
So while I do want to get the 504 fixed, I also am hoping there's a way I could simulate a random Nginx 504 response every now and then.
A simple explanation of a 504 timeout states:
You can simply stop the servers running in development and make a request to Nginx. It won't get a timely response and return a 504.
You can also reduce the timeout duration (60 seconds) by default so you don't have to wait long. e.g. 30 seconds