To configure Nextcloud with Nextcloud-FPM and a bare-metal Nginx server using Docker Compose, you'll need to set up two separate services for Nextcloud-FPM and Nginx. Nextcloud-FPM will host the PHP application and serve it via FastCGI, while Nginx will handle the web server tasks like routing and serving static files. Here's how you can do it:

  1. Create a docker-compose.yml file:
version: '3' services: nextcloud: image: nextcloud:fpm container_name: nextcloud volumes: - nextcloud_data:/var/www/html environment: - - MYSQL_HOST=mysql - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud - MYSQL_PASSWORD=your_mysql_password nginx: image: nginx:latest container_name: nginx volumes: - nextcloud_data:/var/www/html:ro - ./nginx-config:/etc/nginx/conf.d ports: - "80:80" - "443:443" depends_on: - nextcloud volumes: nextcloud_data:
  1. Create a nginx-config directory in the same location as your docker-compose.yml file, and within that directory, create an nginx.conf file:
server { listen 80; server_name; location / { proxy_pass http://nextcloud:9000; 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; } # SSL configuration (optional, if you have SSL certificates) listen 443 ssl; ssl_certificate /path/to/your/ssl/certificate.crt; ssl_certificate_key /path/to/your/ssl/private.key; }
  1. Replace with your actual domain name, and adjust the SSL configuration if you have SSL certificates for your domain.

  2. Run docker-compose up -d to start the Nextcloud and Nginx containers.

With this configuration, Nginx will handle incoming requests and proxy them to the Nextcloud-FPM container, where the PHP application will be served. The two containers will communicate via the internal Docker network.

Make sure to adjust any paths or configuration options based on your setup and requirements. Additionally, ensure that your domain DNS points to the IP address of your server where Nginx is running. If you need SSL support, you should obtain SSL certificates and update the nginx.conf accordingly.

Note: This configuration assumes that you already have a MySQL or MariaDB database set up for Nextcloud. If not, you'll need to create a separate container for the database and configure the nextcloud service to connect to it.

Have questions or queries?
Get in Touch