forked from uishon/Sefaria-Docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added cache service * added volumes to cache Co-authored-by: Ben Edery <[email protected]>
- Loading branch information
Showing
5 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM nginx | ||
|
||
RUN mkdir -p /var/lib/nginx/cache && \ | ||
chown www-data /var/lib/nginx/cache && \ | ||
chmod 700 /var/lib/nginx/cache | ||
|
||
COPY nginx.conf /etc/nginx/nginx.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# daemon off; | ||
error_log /dev/stdout info; | ||
user nginx; | ||
worker_processes 1; | ||
|
||
error_log /var/log/nginx/error.log warn; | ||
pid /var/run/nginx.pid; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
# access_log /var/log/nginx/access.log main; | ||
access_log /dev/stdout; | ||
|
||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_timeout 65; | ||
|
||
|
||
proxy_cache_path /var/lib/nginx/cache levels=1:2 keys_zone=backcache:8m max_size=1g; | ||
|
||
|
||
server { | ||
listen 80; | ||
|
||
proxy_cache_key "$host$request_uri$cookie_user"; | ||
proxy_cache_valid 200 302 10h; | ||
proxy_cache backcache; | ||
proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment; | ||
proxy_ignore_headers Set-Cookie; | ||
|
||
|
||
chunked_transfer_encoding off; | ||
# Enable Gzip compressed. | ||
gzip on; | ||
|
||
# Enable compression both for HTTP/1.0 and HTTP/1.1 (required for CloudFront). | ||
gzip_http_version 1.0; | ||
|
||
# Compression level (1-9). | ||
# 5 is a perfect compromise between size and cpu usage, offering about | ||
# 75% reduction for most ascii files (almost identical to level 9). | ||
gzip_comp_level 5; | ||
|
||
# Don't compress anything that's already small and unlikely to shrink much | ||
# if at all (the default is 20 bytes, which is bad as that usually leads to | ||
# larger files after gzipping). | ||
gzip_min_length 256; | ||
|
||
# Compress data even for clients that are connecting to us via proxies, | ||
# identified by the "Via" header (required for CloudFront). | ||
gzip_proxied any; | ||
|
||
# Tell proxies to cache both the gzipped and regular version of a resource | ||
# whenever the client's Accept-Encoding capabilities header varies; | ||
# Avoids the issue where a non-gzip capable client (which is extremely rare | ||
# today) would display gibberish if their proxy gave them the gzipped version. | ||
gzip_vary on; | ||
|
||
gzip_buffers 16 8k; | ||
|
||
# Compress all output labeled with one of the following MIME-types. | ||
gzip_types | ||
application/atom+xml | ||
application/javascript | ||
application/json | ||
application/rss+xml | ||
application/vnd.ms-fontobject | ||
application/x-font-ttf | ||
application/x-web-app-manifest+json | ||
application/xhtml+xml | ||
application/xml | ||
font/opentype | ||
image/svg+xml | ||
image/x-icon | ||
text/css | ||
text/plain | ||
text/x-component; | ||
location / { | ||
proxy_pass http://web:8000/api/; | ||
} | ||
} | ||
|
||
# include /etc/nginx/conf.d/*.conf; | ||
} |