
먼저 저는 Docker와 서버 관리에 대해 완전히 새로운 사람이라고 말하고 싶습니다.
제가 구축하려는 것은 WordPress
, MariaDB
및 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
for the는 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
다음과 같은 결과가 나타납니다.
내가 뭔가 잘못하고 있는지 확인해 주실 수 있나요? 아침부터 수많은 기사와 스택오버플로우 및 포럼에 대한 답변을 읽었지만 무엇이 잘못되었는지 알 수 없습니다.
어떤 생각이 있으신가요?
메모: 내 개발 환경에 레코드를 추가했습니다.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.