docker撰写nginx代理不重定向

时间:2018-09-11 08:56:41

标签: docker nginx proxy docker-compose

我有一个Ubuntu服务器,并在一个docker容器中构建了一个nginx代理,在另一个容器中构建了一个nginx网络服务器,它们都在同一网络中并且可以互相看到,但是该代理不会重定向到该网络服务器并且在访问我的网站时总是会收到此错误:

proxy      | 2018/09/05 15:30:27 [alert] 8#8: 1024 worker_connections are not enough
proxy      | 2018/09/05 15:30:27 [error] 8#8: *4086 upstream prematurely closed connection while reading response header from upstream, client: 172.18.0.1, server: , request: "GET / HTTP/1.0", upstream: "http://XX.XX.XX.XX:80/", host: "test.com"

这是我的文件:

docker-compose.yml

version: '3'
networks:
    webnet:

services:
  proxy:
    build: ./proxy
    container_name: proxy
    networks:
      - webnet
    ports:
      - 80:80

  website:
    container_name: website
    build: ./nginx
    volumes:
      - ./config/default.conf:/etc/nginx/conf.d/
    networks:
      - webnet

Dockerfile代理

FROM nginx
RUN rm /etc/nginx/nginx.conf

COPY proxy.conf /etc/nginx/nginx.conf

## proxy.conf

events {
  worker_connections 1024;
}

http {
        server {
                listen 80;
                server_name website;

                location / {
                        proxy_pass http://website;
                }
        }
}
```

Dockerfile nginx Web服务器

FROM nginx

RUN rm /usr/share/nginx/html/*
COPY test.com /usr/share/nginx/html

## nginx webserver default.conf
server {
    server_name test.com www.test.com;
    root /usr/share/nginx/html;
    index index.php;
}

0 个答案:

没有答案