Reputation: 81
Let's say i own the domain domain.com
. I want to host, on my Raspberry Pi 4, a PHP website when I go on the URL domain.com
, in parallel with a NextCloud instance when I go to drive.domain.com
.
For this purpose I use Docker and Nginx following this tutorial https://linuxhandbook.com/nginx-reverse-proxy-docker/#step-5-run-other-service-containers-with-reverse-proxy where we setup a VIRTUAL_HOST for each subdomain on the network net
. I managed to get the Nextcloud instance working on my subdomain drive.domain.com
.
When I try the nginx-dummy
example using docker run --rm --name nginx-dummy -e VIRTUAL_HOST=domain.com -e LETSENCRYPT_HOST=domain.com -e VIRTUAL_PORT=80 --network net -d nginx:latest
, it seems to work because the url domain.com
lands the nginx config page. Unfortunately, I didn't manage to change this html page into my PHP website and get it working on domain.com
. Folder being like so:
I tried to create a docker-compose.yml
with Nginx and PHP like so:
version: '3'
services:
# Nginx server configuration
web:
image: nginx:latest
container_name: webserver
environment:
VIRTUAL_HOST: 'domain.com'
VIRTUAL_PORT: 80
depends_on:
- php
links:
- php
volumes:
- ./webcontent:/var/www/html
- ./nginx:/etc/nginx/conf.d/
# Php-fpm configuration
php:
image: php:7.2-fpm
volumes:
- ./webcontent:/var/www/html
- ./php:/usr/local/etc/php/php.ini
but it did not work, returning 502 Bad Gateway
.
Also, Let's encrypt certificates don't seem to be working. Maybe for another question though.
Would you have an idea how to proceed?
Upvotes: 0
Views: 1016
Reputation: 81
After trying several things I found the best solution for my needs. The linuxserver team did an incredible job available here https://docs.linuxserver.io/general/swag#docker-compose.
Their SWAG container setup is easy to follow and really well explained, from setting up a webserver, SSL certificates, and NextCloud in parallel seemlessly. Just a piece of art.
Upvotes: 1