简体   繁体   English

nginx 容器:未知指令“事件”,.conf 错误

[英]nginx container: unknown directive "events", .conf error

I'm using a nginx container with docker lihe proxy server.我正在使用带有 docker lihe 代理服务器的 nginx 容器。 The real function is redirect the request from http://127.0.0.1:7003 to my asp .net rest app with expose port in 5000.真正的功能是将请求从http://127.0.0.1:7003重定向到我的 asp .net rest 应用程序,并在 5000 中公开端口。

So I have been investigating where is the sintaxys error and what is happening.所以我一直在调查 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

So there is my nginx Dockerfile:所以有我的 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/

My docker compose where I put the connexions:我的 docker compose 放置连接的位置:

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

And the most important, the file.conf:最重要的是 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"; 
                } 
    }
}

In your nginx configuration, you have upstrem project-mysql-container ... .在您的 nginx 配置中,您有upstrem project-mysql-container ... That upstrem should be upstream .也就是说upstrem应该是upstream

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 docker 运行命令结束于:nginx:[emerg] 未知指令“events” in /etc/nginx/nginx.conf:1 - docker run command ends up in : nginx: [emerg] unknown directive “events” in /etc/nginx/nginx.conf:1 错误 - nginx: [emerg] "server" 指令在 /etc/nginx/nginx.conf:1 中是不允许的 - Error - nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:1 nginx conf location 指令中的if语句在评估环境变量时抛出错误 - if statement in nginx conf location directive throws error while evaluating environment variable nginx: [emerg] "http" 指令在 /etc/nginx/conf.d/default.conf:1 中是不允许的 - nginx: [emerg] "http" directive is not allowed here in /etc/nginx/conf.d/default.conf:1 nginx: [emerg] "http" 指令在 /etc/nginx/conf.d/site.conf:1 中是不允许的 - nginx: [emerg] "http" directive is not allowed here in /etc/nginx/conf.d/site.conf:1 启动容器时将nginx.conf文件复制到容器中 - Copy nginx.conf file into the container when container is launched 将nginx.conf文件放置在Docker容器中的位置 - Where to place nginx.conf file in docker container Nginx 容器不使用 nginx.conf 除非我重新启动容器 - Nginx container doesn't use nginx.conf unless I restart the container nginx: [emerg] “server”指令在 /etc/nginx/conf.d 中是不允许的,即使服务器标签在 http 中 - nginx: [emerg] “server” directive is not allowed here in /etc/nginx/conf.d even if server tag is inside http Docker Nginx 带有自定义配置文件:未知指令“服务器” - Docker Nginx with custom config file: unknown directive “server”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM