我正在尝试使用此Docker OJS Nginx存储库在带有Nginx 代理自动化的 Docker 中实现 OJS v3 。
我分享我的配置文件:
Dockerfile
我得到了完全相同的Dockerfile
配置文件
基于config.template.inc.php文件,我得到了自己的config.inc.php
文件,其中包含我只更改的以下行:
; The canonical URL to the OJS installation (excluding the trailing slash)
base_url = "www.mydomain.com"
disable_path_info = Off
[database]
; I set the same DB credentials found in the .env
; Default locale
locale = es_ES
[security]
; Force SSL connections site-wide
force_ssl = On
; Force SSL connections for login only
force_login_ssl = On
; The unique salt to use for generating password reset hashes
salt = "Pa*%ThisYnU^0780xaE_C~9)XLonG{Ñj~"
api_key_secret = ""
[proxy]
; Note that allow_url_fopen must be set to Off before these proxy settings
; will take effect.
; The HTTP proxy configuration to use
http_host = www.mydomain.com
http_port = 80
; proxy_username = username
; proxy_password = password
; Since I'm debugging 502, I set On
display_errors = On
码头工人-compose.yml
基于存储库中的这个docker-compose.yml文件,我将其自定义为以下内容:
version: '3.7'
services:
ojs_db:
container_name: ojs_db
image: mariadb:10.2
restart: unless-stopped
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
networks:
- ojs_network
volumes:
- dbvolume:/var/lib/mysql
ojs_app:
container_name: ojs_app
image: ojs-nginx:latest
restart: unless-stopped
networks:
- ojs_network
volumes:
- appvolume:/var/www/html
- mediavolume:/var/www/files
- ./config.inc.php:/var/www/html/config.inc.php
- ./php.ini:/usr/local/etc/php/php.ini
depends_on:
- ojs_db
ojs_nginx:
container_name: ojs_nginx
image: nginx:1.19.2-alpine
restart: unless-stopped
expose:
- "80"
# ports:
# - 8080:8080
networks:
- ojs_network
volumes:
- appvolume:/var/www/html
- ./nginx.conf:/etc/nginx/conf.d/default.conf
depends_on:
- ojs_app
environment:
- VIRTUAL_HOST=${VIRTUAL_HOST}
- LETSENCRYPT_HOST=${VIRTUAL_HOST}
- LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
# smtp:
# image: rordi/docker-mailcatcher
# restart: unless-stopped
# ports:
# - 1080:1080
# networks:
# - ojs_network
volumes:
appvolume:
mediavolume:
dbvolume:
networks:
ojs_network:
driver: bridge
default:
external:
name: ${NETWORK}
nginx.conf
在原来的nginx.conf文件的基础上,我对其进行了如下定制,注意在fastcgi_pass
变量中设置相同的容器名称:
server {
listen 80;
listen [::]:80;
server_name www.mydomain.com;
index index.php index.html index.htm;
root /var/www/html;
client_max_body_size 64m;
location ~ /.well-known/acme-challenge {
allow all;
root /var/www/html;
}
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ ^(.+\.php)(.*)$ {
fastcgi_pass ojs_app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(.*)$;
#fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
#fastcgi_param PATH_INFO $fastcgi_path_info;
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off; access_log off;
}
location = /robots.txt {
log_not_found off; access_log off; allow all;
}
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
}
php.ini
基于原始的 php.ini 文件,我更改了以下内容:
cgi.fix_pathinfo=1
; https://php.net/expose-php
expose_php = Off
max_execution_time = 60
我构建了映像并运行了容器:
$ docker build -t ojs-nginx:latest .
$ docker-compose up -d --build
然而,当我在 (https www) 浏览我的域时,mydomain.com
我收到以下错误:
502错误的网关。Nginx
如果我浏览日志,
docker-compose logs
我会得到:
ojs_app | [19-Feb-2022 18:49:26] NOTICE: fpm is running, pid 1
ojs_app | [19-Feb-2022 18:49:26] NOTICE: ready to handle connections
ojs_db | 2022-02-19 18:49:34 140597536634560 [Note] mysqld: ready for connections.
ojs_db | Version: '10.2.41-MariaDB-1:10.2.41+maria~bionic' socket: '/var/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
ojs_nginx | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
ojs_nginx | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
ojs_nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
ojs_nginx | 10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf
ojs_nginx | 10-listen-on-ipv6-by-default.sh: error: /etc/nginx/conf.d/default.conf differs from the packages version
ojs_nginx | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
ojs_nginx | /docker-entrypoint.sh: Configuration complete; ready for start up
我错过了什么?有什么线索可以让它发挥作用吗?