
まず最初に、私は Docker とサーバー管理について全くの初心者であることを申し上げたいと思います。
WordPress
私が構築しようとしているのは、、MariaDB
およびイメージを含む Docker ベースのスタックですnGinx
。
はnGinx
リバース プロキシとして使用される予定なので、ここにインストールします。
私のはdocker-compose.yml
こんな感じです:
version: '3'
services:
mysql:
image: mariadb
env_file:
- ./.env
volumes:
- ./data:/var/lib/mysql
wordpress:
image: wordpress:php7.2
env_file:
- ./.env
volumes:
- ./wordpress:/var/www/html
ports:
- 42400:80
links:
- mysql
nginx:
build: ./docker/nginx
volumes:
- ./conf/nginx/nginx.conf:/etc/nginx/nginx.conf
ports:
- 80:80
- 443:443
links:
- wordpress
depends_on:
- wordpress
すると、 はDockerfile
次Nginx
のようになります。
FROM nginx:latest
RUN mkdir -p /data/nginx/cache
VOLUME ["/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx"]
EXPOSE 80
EXPOSE 443
WORKDIR /etc/nginx
CMD ["nginx"]
最終的にnGinx
設定ファイルは次のようになります。
daemon off;
worker_processes 1;
events {
worker_connections 1024;
}
http {
sendfile on;
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/xml text/css text/comma-separated-values
text/javascript application/x-javascript application/atom+xml;
upstream wordpress {
server wordpress:42400;
}
server {
listen 80;
server_name www.bimber-viral-buzz.local;
location / {
proxy_pass http://wordpress;
proxy_redirect off;
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-Host $server_name;
}
}
}
さて、 を実行して にdocker-compose up
アクセスしようとするとlocalhost:42400
、WordPress を正常に表示できます。 この場合、問題はなく、WordPress ページを自由にナビゲートできます。
次に、localhost
(ポート番号を指定しない場合はポート80)、次のエラーが発生します。
同時に、コンソールに次のエラーが表示されます。
最後に、割り当てられた IP アドレスを使用してイメージに直接アクセスしようとすると、WordPress
次の出力が表示されます。
私が何か間違ったことをしているかどうかわかりますか? 朝から、stackoverflow やフォーラムでたくさんの記事や回答を読みましたが、何が間違っているのかわかりません。
何かアイデアはありますか?
注記: 私の開発環境では、レコードを追加しました127.0.0.1 www.bimber-viral-buzz.local to access the WordPress site, and you see this domain in the console, because the WordPress forces using the defined domain name.