【发布时间】:2020-12-30 16:01:46
【问题描述】:
我正在尝试使用 nginx 和 docker-compose 设置服务器,但每次尝试“docker-compose up”时都会出现这些错误:
webserver | 2019/06/10 13:04:16 [emerg] 1#1: "http" directive is not allowed here in /etc/nginx/conf.d/default.conf:1
webserver | nginx: [emerg] "http" directive is not allowed here in /etc/nginx/conf.d/default.conf:1
我已经尝试使用 html {} 来结束所有内容,删除服务器 {},另一个端口而不是 80...
nginx Dockerfile
FROM nginx
COPY default.conf /etc/nginx/conf.d/default.conf
default.conf
server {
listen 80;
server_name localhost;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://app:8080/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
【问题讨论】:
-
远程进入容器并检查所有文件,确保正确的文件位于正确的位置并包含预期的内容。
-
我什至不能这样做,因为容器在这些错误之后不会启动。