2021-05-23 06:27:02 +00:00
|
|
|
include /etc/nginx/conf.d/server_config;
|
|
|
|
|
2020-05-18 03:20:51 +00:00
|
|
|
upstream web {
|
|
|
|
server web:8000;
|
|
|
|
}
|
|
|
|
|
|
|
|
server {
|
2022-12-06 12:56:58 +00:00
|
|
|
access_log /var/log/nginx/access.log cache_log;
|
|
|
|
|
2020-05-18 03:20:51 +00:00
|
|
|
listen 80;
|
|
|
|
|
2022-12-06 12:56:58 +00:00
|
|
|
sendfile on;
|
|
|
|
tcp_nopush on;
|
|
|
|
tcp_nodelay on;
|
|
|
|
keepalive_timeout 65;
|
|
|
|
types_hash_max_size 2048;
|
|
|
|
#include /etc/nginx/mime.types;
|
|
|
|
#default_type application/octet-stream;
|
|
|
|
|
|
|
|
gzip on;
|
|
|
|
gzip_disable "msie6";
|
|
|
|
|
|
|
|
proxy_read_timeout 1800s;
|
|
|
|
chunked_transfer_encoding on;
|
|
|
|
|
|
|
|
# store responses to anonymous users for up to 1 minute
|
|
|
|
proxy_cache bookwyrm_cache;
|
|
|
|
proxy_cache_valid any 1m;
|
|
|
|
add_header X-Cache-Status $upstream_cache_status;
|
|
|
|
|
|
|
|
# ignore the set cookie header when deciding to
|
|
|
|
# store a response in the cache
|
|
|
|
proxy_ignore_headers Cache-Control Set-Cookie Expires;
|
|
|
|
|
|
|
|
# PUT requests always bypass the cache
|
|
|
|
# logged in sessions also do not populate the cache
|
|
|
|
# to avoid serving personal data to anonymous users
|
|
|
|
proxy_cache_methods GET HEAD;
|
|
|
|
proxy_no_cache $cookie_sessionid;
|
|
|
|
proxy_cache_bypass $cookie_sessionid;
|
|
|
|
|
|
|
|
# tell the web container the address of the outside client
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_redirect off;
|
|
|
|
|
|
|
|
# rate limit the login or password reset pages
|
2022-11-02 01:17:37 +00:00
|
|
|
location ~ ^/(login[^-/]|password-reset|resend-link|2fa-check) {
|
2022-07-15 20:14:31 +00:00
|
|
|
limit_req zone=loginlimit;
|
|
|
|
proxy_pass http://web;
|
|
|
|
}
|
|
|
|
|
2022-12-06 12:56:58 +00:00
|
|
|
# do not log periodic polling requests from logged in users
|
|
|
|
location /api/updates/ {
|
|
|
|
access_log off;
|
2020-05-18 03:20:51 +00:00
|
|
|
proxy_pass http://web;
|
|
|
|
}
|
|
|
|
|
2022-12-06 12:56:58 +00:00
|
|
|
# forward any cache misses or bypass to the web container
|
|
|
|
location / {
|
|
|
|
proxy_pass http://web;
|
2020-05-18 03:20:51 +00:00
|
|
|
}
|
|
|
|
|
2022-12-06 12:56:58 +00:00
|
|
|
# directly serve images and static files from the
|
|
|
|
# bookwyrm filesystem using sendfile.
|
|
|
|
# make the logs quieter by not reporting these requests
|
|
|
|
location ~ ^/(images|static)/ {
|
|
|
|
root /app;
|
|
|
|
try_files $uri =404;
|
|
|
|
add_header X-Cache-Status STATIC;
|
|
|
|
access_log off;
|
2020-05-18 03:20:51 +00:00
|
|
|
}
|
2022-12-06 12:58:05 +00:00
|
|
|
|
|
|
|
# monitor the celery queues with flower, no caching enabled
|
|
|
|
location /flower/ {
|
|
|
|
proxy_pass http://flower:8888;
|
|
|
|
proxy_cache_bypass 1;
|
|
|
|
}
|
2020-05-18 03:20:51 +00:00
|
|
|
}
|