我有这个Nginxconfiguration大多数工作,我想要的方式,它:
注意:这是一个envsubst
模板。
location / { 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; proxy_set_header Host $http_host; proxy_redirect off; proxy_read_timeout 60; proxy_next_upstream error timeout http_500 http_502 http_503 http_504; proxy_buffers 16 64k; proxy_buffer_size 2k; proxy_temp_file_write_size 64k; proxy_pass http://nodejs; proxy_intercept_errors on; recursive_error_pages on; error_page 404 = @legacy; location /404 { # serve up /404 from the node server internal; proxy_intercept_errors off; recursive_error_pages off; proxy_pass http://nodejs; } } location @legacy { # when we can't find a page on the new server, try to find it on the # old web server. If still not found, show new site's 404 page. # NOTE: unfortunately, this can result in a 2nd call to our node # servers, even though we already have the response from them. proxy_pass ${LEGACY_URL}; proxy_redirect default; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_intercept_errors on; recursive_error_pages on; error_page 404 = /404; }
问题是:
有什么办法让Nginx在这一点上返回原始的404节点响应呢?