我正在通过dockerfile使用node和nginx创建一个容器。它无缝发生。 但是,当我运行它时,出现以下错误。 我不知道这个。你能帮我吗?
2019/11/11 18:50:49 [emerg] 12#12: host not found in upstream "myproject-frontend:3000" in /etc/nginx/conf.d/default.conf:2
nginx: [emerg] host not found in upstream "myproject-frontend:3000" in /etc/nginx/conf.d/default.conf:2
nginx:在上游找不到[emerg]主机
# Stage 1
FROM node:latest as react-build
WORKDIR /app
COPY . ./
RUN yarn
RUN yarn build
# Stage 2 - the production environment
FROM andreilhicas/nginx-letsencrypt AS production
COPY ./nginx/nginx-tmp.conf /etc/nginx/conf.d/default.conf
COPY --from=react-build /app/build /usr/share/nginx/html
EXPOSE 3000
ENTRYPOINT ["./nginx-letsencrypt"]
upstream restgunicorn_server{
server myproject-frontend:3000;
}
server {
listen 80;
server_name localhost;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name localhost;
resolver 127.0.0.11 valid=30s;
location / {
proxy_pass http://restgunicorn_server;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
ssl_certificate /usr/share/nginx/certificates/fullchain.pem;
ssl_certificate_key /usr/share/nginx/certificates/privkey.pem;
include /etc/ssl-options/options-nginx-ssl.conf;
ssl_dhparam /etc/ssl-options/ssl-dhparams.pem;
}