我想使用docker-compose使用letencrypt和nginx运行php网站。但这是行不通的。我试图使用其他简单的网页(而不是php),例如:index.html,它可以工作。
我的docker-compose文件基于以下项目:https://github.com/gilyes/docker-nginx-letsencrypt-sample/blob/master/docker-compose.yml。
请帮助我,使用php,谢谢。
version: "2"
services:
nginx:
restart: always
image: nginx
container_name: nginx
ports:
- "80:80"
- "443:443"
volumes:
- "/etc/nginx/conf.d"
- "/etc/nginx/vhost.d"
- "./website:/usr/share/nginx/html"
- "./volumes/proxy/certs:/etc/nginx/certs:ro"
depends_on:
- fpm
nginx-gen:
restart: always
image: jwilder/docker-gen
container_name: nginx-gen
volumes:
- "/var/run/docker.sock:/tmp/docker.sock:ro"
- "./volumes/proxy/templates/nginx.tmpl:/etc/docker-gen/templates/nginx.tmpl:ro"
volumes_from:
- nginx
entrypoint: /usr/local/bin/docker-gen -notify-sighup nginx -watch -wait 5s:30s /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
letsencrypt-nginx-proxy-companion:
restart: always
image: jrcs/letsencrypt-nginx-proxy-companion
container_name: letsencrypt-nginx-proxy-companion
volumes_from:
- nginx
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./volumes/proxy/certs:/etc/nginx/certs:rw"
environment:
- NGINX_DOCKER_GEN_CONTAINER=nginx-gen
fpm:
restart: always
build: ./php-fpm
ports:
- "9000"
container_name: fpm-website
volumes:
- "./website:/usr/share/nginx/html" # folder with web-site
- "./php-fpm/php.ini-production.ini:/usr/local/etc/php/php.ini:ro"
environment:
- VIRTUAL_HOST=website.com
- LETSENCRYPT_HOST=website.com
- LETSENCRYPT_EMAIL=ser@website.com
这是我的“ fpm”容器的Dockerfile:
FROM php:7.3.2-fpm-alpine
RUN apk update; \
apk upgrade;
RUN docker-php-ext-install mysqli
当我尝试打开页面时,我收到一条消息:
502错误的网关 nginx / 1.15.12