使用nginx设置微服务超时

使用nginx设置微服务超时,nginx,Nginx,当传入具有特定性能要求的请求时,我有一个微服务。如果超过两秒钟,它必须以特定的响应失败。设置nginx.conf文件以支持此操作的最佳方法是什么?因此,答案似乎是,对于cavet,超时响应的端点必须与原始微服务调用的端点相同 server { listen 9000; server_name localhost; location /microservice { proxy_pass http://127.0.0.1:8080; pr

当传入具有特定性能要求的请求时,我有一个微服务。如果超过两秒钟,它必须以特定的响应失败。设置nginx.conf文件以支持此操作的最佳方法是什么?

因此,答案似乎是,对于cavet,超时响应的端点必须与原始微服务调用的端点相同

server {
   listen       9000;
   server_name  localhost;

   location /microservice {
       proxy_pass http://127.0.0.1:8080;
       proxy_intercept_errors on;
       proxy_read_timeout 2s;
       error_page 504 =200 @timeout;
   }

   location @timeout {
      proxy_pass http://127.0.0.1:8081;
   }