nginx, Plone Classic container example#

This example is a simple setup with one backend and data being persisted in a Docker volume.

nginx in this example is used as a reverse proxy.

Setup#

Create an empty project directory named nginx-plone.

mkdir nginx-plone

Change into your project directory.

cd nginx-plone

nginx configuration#

Add a default.conf that will be used by the nginx image:

upstream backend {
  server backend:8080;
}

server {
  listen 80 default_server;
  server_name plone.localhost;

  location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_redirect http:// https://;
    if (!-f $request_filename) {
      rewrite ^/(.*)$ /VirtualHostBase/http/plone.localhost:80/Plone/VirtualHostRoot/$1;
    }
  }

  location /VirtualHostBase/ {
    proxy_pass http://backend;
  }
}

Note

http://plone.localhost/ is the URL you will be using to access the website. You can either use plone.localhost, or add it in your /etc/hosts file or DNS, to point to the Docker host IP.

Service configuration with Docker Compose#

Now let's create a docker-compose.yml file:

services:

  webserver:
    image: nginx
    volumes:
      - ./default.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - backend
    ports:
    - "80:80"

  backend:
    image: plone/plone-backend:${STACK_BACKEND_TAG:?Set STACK_BACKEND_TAG}
    environment:
      SITE: Plone
      TYPE: classic
    volumes:
      - vol-site-data:/data
    ports:
    - "8080:8080"

volumes:
  vol-site-data: {}

Environment variables#

The docker-compose.yml file reads the tags of its images from the following environment variables. All of them are required, and docker compose stops with an error if one of them is missing.

Variable

Description

Default value

Example

STACK_BACKEND_TAG

Tag (version) of the image for the backend

6.2

Create a .env file in your project directory with your values. Docker Compose reads it automatically when you run docker compose from that directory.

STACK_BACKEND_TAG=6.2

Build the project#

Start the stack with docker compose.

docker compose up -d

This pulls the needed images and starts Plone.

Access Plone via Browser#

After startup, go to http://plone.localhost/ and you should see the site. You can also open the main Plone control page where you can create more Plone sites at http://plone.localhost:8080.

Shutdown and cleanup#

The command docker compose down removes the containers and default network, but preserves the Plone database.

The command docker compose down --volumes removes the containers, default network, and the Plone database.