这曾经工作:
server { server_name example.com; location / { proxy_pass http://localhost:8888; error_page 502 /502.html; } location = /502.html { root /var/www/example; } }
现在突然间它不再…我不知道什么改变了?
如果端口8888不响应,我得到404而不是显示/var/www/example/index.html …
如何使这个工作再次? 谢谢
您的大部分内容位于远程服务器上。 您需要在本地提供错误页面(连同一些资源)。 您需要一个与上游服务地点不同的“特殊位置”,并将所有本地资源都放在那里。 我不能为那个位置select一个名字,因为我不知道你从/error_pages提供什么。但现在可以说/error_pages 。
server { server_name example.com; location / { proxy_pass http://localhost:8888; error_page 502 /error_pages/502.html; } location /error_pages { root /var/www/example; } }
通过上述configuration,您将需要编辑502.html并更改资源的URL以添加/error_pages前缀。
您还需要将所有文件( 502.html及其资源文件)移动到/var/www/example/error_pages/子目录中。
您的configuration指出错误文档是/var/www/example/502.html 。 你的configuration中没有任何东西可以随时加载/var/www/example/index.html 。 重命名文件。