【发布时间】:2023-03-26 18:42:01
【问题描述】:
我正在尝试在托管多个网站的机器上部署 nginx/gunicorn/django 堆栈。而且我可以在最终需要的 80 端口以外的任何其他端口上执行此操作,因为 HTTP 守护程序正在使用它。而且我不知道杀死 httpd 进程的后果。在我部署 docker 之前,php 是用 cpanel 在这个网站上运行的。
使用 :80 端口的进程是
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 22466/httpd
tcp6 0 0 :::80 :::* LISTEN 22466/httpd
有什么建议或想法吗?
编辑: 我用于工作 8000 端口的配置文件,当我将端口更改为 80 时,我遇到了这个问题:
docker-compose.yml
version: '2'
services:
nginx:
image: nginx:latest
container_name: ng01
ports:
- "8000:8000"
volumes:
- ./src:/src
- ./config/nginx:/etc/nginx/conf.d
- /static:/static
- ./src/media:/media
depends_on:
- web
web:
build: .
container_name: dg01
command: bash -c "python manage.py collectstatic --no-input && python manage.py makemigrations && python manage.py migrate && gunicorn mydjango.wsgi -b 0.0.0.0:8000"
depends_on:
- db
volumes:
- ./src:/src
- /static:/static
- /media:/media
expose:
- "8000"
db:
image: postgres:latest
container_name: ps01
nginx 配置
upstream web {
ip_hash;
server web:8000;
}
server {
location /static/ {
autoindex on;
alias /static/;
}
location /media/ {
autoindex on;
alias /media/;
}
location / {
proxy_pass http://web/;
}
listen 8000;
server_name server_domain_here;
}
【问题讨论】: