setup caching in NGINX

This commit is contained in:
Brett 2022-07-20 14:41:52 +02:00
parent 3dd6761d21
commit 650d01ba51
3 changed files with 41 additions and 8 deletions

View File

@ -24,9 +24,8 @@ NB: Had to update the prerun.py script as it was failing on check_solr_connecti
### ToDo (remaining things to think about and/or 'to fix') ### ### ToDo (remaining things to think about and/or 'to fix') ###
1. nginx - what caching should I implement? 1. DataPusher - needed to use a custom requirements.txt as the official didn't work (see https://github.com/ckan/datapusher/pull/251)
2. DataPusher - needed to use a custom requirements.txt as the official didn't work (see https://github.com/ckan/datapusher/pull/251) 2. Use Multi-Stage images defined in Dockerfile - get the CKAN images down to bare-bones...for security reasons really
3. Use Multi-Stage images defined in Dockerfile - get the CKAN images down to bare-bones...for security reasons really
General Dockerfile flow of stages: General Dockerfile flow of stages:
- base: all prod dependencies, no code yet - base: all prod dependencies, no code yet
- dev, from base: all dev dependencies, no code yet (in dev, source code is bind-mounted anyway) - dev, from base: all dev dependencies, no code yet (in dev, source code is bind-mounted anyway)
@ -34,5 +33,5 @@ NB: Had to update the prerun.py script as it was failing on check_solr_connecti
- test/audit, from source: then COPY --from=dev for dev dependencies, then run tests. Optionally, audit and lint code (if you don't do it on git push already). - test/audit, from source: then COPY --from=dev for dev dependencies, then run tests. Optionally, audit and lint code (if you don't do it on git push already).
- prod, from source: no change from source stage, but listed last so in case a stage isn't targeted, the builder will default to this stage - prod, from source: no change from source stage, but listed last so in case a stage isn't targeted, the builder will default to this stage
Also check out https://github.com/ckan/ckan/pull/4635 for Francesco's test stuff Also check out https://github.com/ckan/ckan/pull/4635 for Francesco's test stuff
4. CKAN Worker (maybe) 3. CKAN Worker (maybe)
5. Implement SSL for the nginx container or include a howto in the docs 4. Implement SSL for the nginx container or include a howto in the docs

View File

@ -2,9 +2,8 @@ FROM nginx:stable-alpine
ENV NGINX_DIR=/etc/nginx ENV NGINX_DIR=/etc/nginx
COPY setup/nginx.conf ${NGINX_DIR}/nginx.conf
COPY setup/index.html /usr/share/nginx/html/index.html COPY setup/index.html /usr/share/nginx/html/index.html
COPY setup/*.conf ${NGINX_DIR}/conf.d/ COPY setup/default.conf ${NGINX_DIR}/conf.d/
#RUN mkdir -p /tmp/nginx/cache
EXPOSE 81 EXPOSE 81

35
nginx/setup/nginx.conf Normal file
View File

@ -0,0 +1,35 @@
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
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;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
proxy_cache_path /tmp/nginx_cache levels=1:2 keys_zone=cache:30m max_size=250m;
proxy_temp_path /tmp/nginx_proxy 1 2;
include /etc/nginx/conf.d/*.conf;
}