ПРИМЕЧАНИЕ: Я безуспешно пробовал официальную Nuxt / Nginx config . Я продолжаю получать эту ошибку
2020/07/10 18:41:57 [error] 6#6: *11 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.96.1, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "localhost"
, когда использую proxy_pass http://127.0.0.1:3000
, proxy_pass http://localhost:3000
или proxy_pass http://0.0.0.0:3000
Когда я пытаюсь изменить эту запись на proxy_pass http://container_name:3000
, я получаю новую ошибку
2020/07/10 14:16:58 [emerg] 1#1: host not found in upstream "container_name" in /etc/nginx/conf.d/app.conf:25
Мой docker -compose.yml файл выглядит примерно так:
version: '3'
networks:
nuxtnet:
services:
nuxt:
image: node
container_name: nuxt
volumes:
- ./client/:/var/www/html/client/
working_dir: /var/www/html/client/
environment:
- HOST=0.0.0.0
- PORT=3000
command: npm run dev
nginx:
image: nginx
container_name: nginx
ports:
- 80:80
volumes:
- ./client/:/var/www/html/client/
- ./config/nginx/conf.d/:/etc/nginx/conf.d/
- ./nginx/logs/:/var/log/nginx/
depends_on:
- nuxt
networks:
- nuxtnet
Мой app.conf
nginx файл выглядит так:
map $sent_http_content_type $expires {
"text/html" epoch;
"text/html; charset=utf-8" epoch;
default off;
}
server {
listen 80; # the port nginx is listening on
server_name myapp.dev; # setup your domain here
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
location / {
expires $expires;
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-Proto $scheme;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://localhost:3000; # set the address of the Node.js instance here
}
}
При запуске docker-compose up
с другой репликой этого проекта, выполняющей PHP и MySQL, этот поток выглядит незаметно, но в этом проекте я получаю по умолчанию Nginx ошибку оплаты 502 Bad Gateway
независимо от того, что я поместите в поле proxy_pass
конфигурации nginx. Пожалуйста, помогите мне с любыми идеями, которые избавят вас от этого кошмара go. Заранее спасибо.