【问题标题】:nginx container: unknown directive "events", .conf errornginx 容器:未知指令“事件”,.conf 错误
【发布时间】:2020-01-28 16:56:24
【问题描述】:

我正在使用带有 docker lihe 代理服务器的 nginx 容器。真正的功能是将请求从http://127.0.0.1:7003 重定向到我的asp .net rest 应用程序,并在5000 中公开端口。

所以我一直在调查sintaxys错误在哪里以及发生了什么。

nginx-container  | 2020/01/28 08:34:06 [emerg] 1#1: unknown directive "events" in /etc/nginx/conf.d/Local.Project.Core.conf:1
nginx-container  | nginx: [emerg] unknown directive "server" in /etc/nginx/conf.d/Local.Project.Core.conf:1

于是有了我的 nginx Dockerfile:

FROM nginx:latest

# Copy virtual hosts config
RUN rm /etc/nginx/conf.d/default.conf
COPY ./wwwroot/config/Local.Project.Core.conf /etc/nginx/conf.d/

我的 docker 撰写我放置连接的位置:

local-project:
      image: project-mysql-image
      container_name: project-mysql-container
      ports:        
        - 127.0.0.1:7000:80
        - 127.0.0.1:7001:433
        - 127.0.0.1:7002:5000
      expose:
        - "5000"
      environment:
        ASPNETCORE_ENVIRONMENT: Production
        ASPNETCORE_URLS: http://+:80;http//+:433;http:+:5000 # Is going to use Kestrel standard 5000 port, only http connection
        ASPNETCORE_Kestrel__Certificates__Default__Path: /etc/ssl/certs/Local.Proyect.Core.pfx
        ASPNETCORE_Kestrel__Certificates__Default__Password: local 

      volumes:
        - .\wwwroot\cer\Local.Proyect.Core.cer:/etc/ssl/certs/Local.Proyect.Core.pfx

    nginx:
      image: nginx-image
      container_name: nginx-container
      ports: 
        - 127.0.0.1:7003:80

最重要的是file.conf:

events {
            worker_connections  1024;
            multi_accept  on;
            use  epoll;  
} 
http {

    include /etc/nginx/sites-enabled/*;

    upstrem project-mysql-container { server project-mysql-container:5000; }    

    server { 
                listen  80; 

                root /;

                index  index.html index.htm index.nginx-debian.html;

                server_name  *.Local.Project.Core;

                location / {
                        proxy_pass              http://project-mysql-container:5000; 
                }

                location /ws/ { 
                        proxy_pass              http://project-mysql-container:5000/ws/; 
                        proxy_http_version      1.1; 
                        proxy_set_header        Upgrade $http_upgrade; 
                        proxy_set_header        Connection "Upgrade"; 
                } 
    }
}

【问题讨论】:

    标签: docker nginx


    【解决方案1】:

    在您的 nginx 配置中,您有 upstrem project-mysql-container ...upstrem 应该是 upstream

    【讨论】:

      猜你喜欢
      • 2011-07-15
      • 2011-12-12
      • 1970-01-01
      • 1970-01-01
      • 2018-11-23
      • 1970-01-01
      • 2020-08-04
      • 1970-01-01
      • 2011-12-12
      相关资源
      最近更新 更多