nginx: Use the Django 404 page for files under static/.

This elimintes the need for us to maintain duplicate copies of the
Zulip 404 error pages.

Fixes #5382.
This commit is contained in:
Tim Abbott 2017-07-16 16:34:05 -07:00
parent a05de7ce84
commit 2317819e47
5 changed files with 10 additions and 38 deletions

View File

@ -63,7 +63,7 @@ If you want to test minified files in development, look for the
`PIPELINE_ENABLED =` line in `zproject/settings.py` and set it to `True`
-- or just set `DEBUG = False`.
Note that `static/html/{400,5xx}.html` will only render properly if
Note that `static/html/5xx.html` will only render properly if
minification is enabled, since they, by nature, hardcode the path
`static/min/portico.css`.

View File

@ -33,10 +33,15 @@ likely culprit.
Static files include JavaScript, css, static assets (like emoji, avatars),
and user uploads (if stored locally and not on S3).
File not found errors (404) are served using a Django URL, so that we
can use configuration variables (like whether the user is logged in)
in the 404 error page.
```
location /static/ {
alias /home/zulip/prod-static/;
error_page 404 /static/html/404.html;
# Set a nonexistent path, so we just serve the nice Django 404 page.
error_page 404 /django_static_404.html;
}
```

View File

@ -10,7 +10,8 @@ error_page 502 503 504 /static/html/5xx.html;
# Serve static files directly
location /static/ {
alias /home/zulip/prod-static/;
error_page 404 /static/html/404.html;
# Set a nonexistent path, so we just serve the nice Django 404 page.
error_page 404 /django_static_404.html;
}
# Send longpoll requests to Tornado

View File

@ -1,29 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Zulip, from Zulip, Inc.</title>
<link href="/static/third/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="/static/third/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<!-- NB: Relies on the fact that PipelineCachedStorage also includes
a copy of the file with no hash in the name.
This file will not load in dev unless you run `manage.py collectstatic`. -->
<link href="/static/min/portico.css" rel="stylesheet">
</head>
<body class="error_page">
<div class="container">
<div class="row-fluid">
<img src="/static/images/400art.svg" alt=""/>
<div class="errorbox">
<div class="errorcontent">
<h1 class="lead">Page not found (404)</h1>
<p>We can't find the page you're looking for.</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -42,15 +42,10 @@
<td>None needed</td>
<td>Preview all email templates</td>
</tr>
<tr>
<td><a href="/static/html/404.html">/static/html/404.html</a></td>
<td><code>./manage.py collectstatic --noinput</code></td>
<td>Error 404 page served by nginx</td>
</tr>
<tr>
<td><a href="/static/html/5xx.html">/static/html/5xx.html</a></td>
<td><code>./manage.py collectstatic --noinput</code></td>
<td>Error 5xx page served by nginx</td>
<td>Error 5xx page served by nginx (used when Django is totally broken)</td>
</tr>
<tr>
<td><a href="/errors/404">/errors/404</a></td>