【发布时间】:2021-05-09 09:20:22
【问题描述】:
我在让 wordpress docker 镜像与 nginx docker 镜像一起工作时遇到问题。
python/django 容器与 nginx 完美配合,但 wordpress/apache 有问题。我可以使用 https 访问 django 站点。我无法使用 https 进入 wordpress 之一。事实上,当我访问我的站点 site.com/wp 时,我会返回 site.com:8080/wp,所以由于某种原因它是通过端口返回的8080,而不是 443 或 80。我尝试将 wordpress 站点设置为根位置 /(在 default.conf 文件中),但仍然存在同样的问题(然后我得到 site.com:8080)。 wordpress 功能正常,我可以照常编辑网站。
nginx 的 default.conf 文件
disable_symlinks off;
ssl_certificate xxx
ssl_certificate_key xxx
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name site.com;
location / {
proxy_pass http://django:8000; #django container
}
location /static {
alias /path/to/static;
}
location /wp {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://wordpress:80; #the wordpress container
}
}
码头工人 yml
version: '3.7'
services:
django:
restart: always
build:
context: .
dockerfile: docker-django #django gunicorn server, python image
ports:
- "8000:8000"
wordpress:
restart: always
build:
context: .
dockerfile: docker-wordpress #docker wordpress-apache image
# image: wordpress:latest
volumes:
- ./www/html:/var/www/html
- ./etc/apache2:/etc/apache2
ports:
- "8080:80"
nginx:
restart: always
build:
context: .
dockerfile: docker-nginx #docker nginx image
# image: nginx
volumes:
- ./xx/static:/usr/xx/static
- ./nginx/conf.d:/etc/nginx/conf.d
ports:
- "443:443"
- "80:80"
depends_on:
- django
- wordpress
【问题讨论】:
标签: django wordpress docker nginx