这是我的服务器配置:
server {
listen 0.0.0.0;
server_name dev.host.com;
location / {
include /etc/nginx/proxy.conf;
proxy_pass http://127.0.0.1:5000;
proxy_redirect default;
error_page 502 =200 @maintenance;
}
location ^~ /(img|js|css)/ {
root /path/to/application/assets;
expires max;
break;
error_page 404 =302 /;
}
location @maintenance {
root /path/to/static/offline/files;
try_files $uri $uri/ /index.html =503;
}
}
Run Code Online (Sandbox Code Playgroud)
当上游应用程序不在线时,我将获得根路径的默认 nginx 502 页面(即 : GET /)。知道为什么会这样吗?我希望根路径像任何其他请求路径一样响应维护页面。
细节决定成败;我的@maintenance命名位置设置不正确。具体来说,发送参数 ( $uri/)try_files导致了该问题。这是正确的命名位置:
location @maintenance {
root /path/to/static/offline/files;
try_files $uri /index.html =503;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8498 次 |
| 最近记录: |