NGINX SSL config

This commit is contained in:
Brett 2022-08-16 14:02:49 +02:00
parent 650d01ba51
commit 1f3a50a476
7 changed files with 98 additions and 2 deletions

View File

@ -9,6 +9,7 @@
* [Extending the base images](#extending-the-base-images)
* [Applying patches](#applying-patches)
* [Debugging with pdb](#pdb)
* [NGINX](#nginx)
* [Known Issues](#known-issues)
@ -24,6 +25,7 @@ The non-CKAN images are as follows:
* PostgreSQL: Official PostgreSQL image. Database files are stored in a named volume.
* Solr: CKAN's [pre-configured Solr image](https://github.com/ckan/ckan-solr). Index data is stored in a named volume.
* Redis: standard Redis image
* NGINX: latest stable nginx image
The site is configured via env vars (the base CKAN image loads [ckanext-envvars](https://github.com/okfn/ckanext-envvars)), that you can set in the `.env` file.
@ -149,6 +151,10 @@ Debug with pdb (example) - Interact with `docker attach $(docker container ls -q
command: `python -m pdb /usr/lib/ckan/venv/bin/ckan --config /srv/app/ckan.ini run --host 0.0.0.0 --passthrough-errors`
## NGINX
* The base Docker Compose configuration uses an NGINX image as the front-end (ie: reverse proxy). It includes HTTPS running on port number 443. A "self-signed" SSL certificate is generated beforehand and the server certificate and key files are included. The NGINX server_name directive and the CN field in the SSL certificate have been both ser to 'localhost'. This should obviously not be used for production.
## Known Issues
* Running the tests: Running the tests for CKAN or an extension inside the container will delete your current database. We need to patch CKAN core in our image to work around that.

View File

@ -9,4 +9,4 @@ RUN echo ${TZ} > /etc/timezone
# Make sure both files are not exactly the same
RUN if ! [ /usr/share/zoneinfo/${TZ} -ef /etc/localtime ]; then \
cp /usr/share/zoneinfo/${TZ} /etc/localtime ;\
fi ;
fi ;

View File

@ -18,7 +18,8 @@ services:
ckan:
condition: service_healthy
ports:
- "0.0.0.0:81:80"
- "0.0.0.0:80:80"
- "0.0.0.0:443:443"
ckan:
container_name: ${CKAN_CONTAINER_NAME}

View File

@ -6,4 +6,7 @@ COPY setup/nginx.conf ${NGINX_DIR}/nginx.conf
COPY setup/index.html /usr/share/nginx/html/index.html
COPY setup/default.conf ${NGINX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rIWScsFAXpDcm4Rc/Zqi/73iOywGabKE+uAgNilvMBZeZoVf+yGvhYI/SNW6
4v68D4omY+VQM1xeCxAoRDJuKn0KbH62Wz4dOzGvj2abPS4Ib6Aul5HmlfOXCS5L
ilj2Ek3PZViFEDfZR0rioCzg5whFjHyEN/Q6HTFI3wKCAQEAgaI5lOLsU4qHeKvM
Ph79zia4y6xMlk8lS0gWI+hGA5qNtMPqGAgceTBICMhZUwPUy2lf21dS/LNAw3ox
174+8IQ98hyLe/BGO+syN1uuLmtr5WGiYNLUkhF3h2RuyFi0LmTi9hHHyKWA7AeF
KL5QUgAgwIxvKZBsnEfo1Naw5k9RyruFLV32QN1NYH0VfH62Tsh0txfmwe9Sjn4S
JCipVpakS0GNuYbgGYdrmBChDaRQP/gc1wa92wsHoAfQlrS6mZGwFNv4LFNGIEOw
V07OqQL/kt1nn/6bLlu7MVjj+QjDiFK/361dvYmlpZxDUD0llx2XGo4WLAWzFKlu
ceH9LQKCAQEA2gzqZpZHtZQCN8spL5McTCY+uDdkyCHF8DE9e2Pd8DR6uACIGm5a
+29d5yXZEJPmWqxhMNoGAJI7XA+xkALYcKchrpLKqUBPBRzzH3jmUFcB3kRNbLek
cohLTWGcqkP8KAhpTtIGVgFAJ1Gsu5DWnwolVaC3TqdtbUSUCoDI9iI/UYQHBot9
FAbXKJ3SUtKZdpOmCoMnErn+KXj5B2CHyHXVH5QMp7mX6MZHpuXb/jtI/Cp/HQ/R
COnLAucndNeLWZ08NNIs3tfXStav6YnA1KLWBA0SEA8taXEgTGGB0KZoTG4+czri
3NZYHoZNqp79Kl0T6Y0VWI/CpXCS7kgT9A==
-----END PRIVATE KEY-----

View File

@ -1,7 +1,11 @@
server {
listen 80;
listen [::]:80;
listen 443 ssl;
listen [::]:443 ssl;
server_name localhost;
ssl_certificate /etc/nginx/certs/ckan-local.crt;
ssl_certificate_key /etc/nginx/certs/ckan-local.key;
#access_log /var/log/nginx/host.access.log main;