When doing node isomorphism, now I want to let nginx directly return static resources when the server is called. How should I configure nginx?
For example, visit a.xx.com/test.html,
When the node server hangs up, let nginx directly return the static file of test.html. Is there a way to achieve this?
曾经蜡笔没有小新2017-05-16 17:17:11
Use proxy_intercept_errors + error_page to solve your problem.
error_page 504 /$uri
504 means that the proxy times out
phpcn_u15822017-05-16 17:17:11
We originally encountered your problem when we were publishing. When we were publishing, we needed to stop the service
But we hope to have a friendly page to remind users that we are serving and please try again later. We use nginx's load balancing to start two services. 10.0.0.2 runs to prompt users that we are releasing a version and prompts users to use the service.
upstream my_server {
server 10.0.0.1:8080 weight=10;
server 10.0.0.2:8080 backup; //当其它服务器挂掉的时候才会负载到这台
keepalive 2000;
}
server {
listen 80;
server_name www.test.com;
location / {
proxy_pass http://my_server;
}
}