Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

324
Vistas
docker run command ends up in : nginx: [emerg] unknown directive “events” in /etc/nginx/nginx.conf:1

I have installed nginx-extras from Ubuntu bash shell in my desktop Windows 10 O.S. The is required to spin up a docker container for an ASP.NET Core 3.1 Blazor web assembly application for serving the static web pages. My nginx.conf:

 events { }
   http {
      include mime.types;
      types {
         application/wasm wasm;
       }
     server {
        listen 80;
        index index.html;
        location / {
           root /var/www/web;
           try_files $uri $uri/ /index.html =404;
        }
     }
}

Dockerfile:

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
COPY . ./
RUN dotnet publish -c Release -o output

FROM nginx:alpine
WORKDIR /var/www/web
COPY --from=build-env /app/output/wwwroot .
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80

My build command was successful.

However when I wanted to create a container using the command: docker run -p 8080:80 docker-wasm-blazor It gave me an error:

[emerg] 1#1: unknown directive "events" in /etc/nginx/nginx.conf:1 nginx: [emerg] unknown directive "events" in /etc/nginx/nginx.conf:1

I am very new to nginx and containerisation, so any help will be highly appreciated. Thanks.

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

I had the same error. Fixed by changing the encoding of the nginx.conf file. If you create the nginx.conf file in/with visual studio (Add -> new File) it's most likely that your will get the wrong encoding (other people got the same error).

In my case the encoding was UTF-8 and I needed us-ascii encoding. The easiest was to delete my nginx.conf file and recreate it outside of visual studio (I used Sublime text but I think you can use notepad).

over 4 years ago · Santiago Trujillo Denunciar

0

I sorted out the issue by excluding the custom nginx.conf file to copy over the default nginx.conf file by removing the last line from the dockerfile. Now my dockerfile looks like this: FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env WORKDIR /app COPY . ./ RUN dotnet publish -c Release -o output

FROM nginx WORKDIR /usr/share/nginx/html COPY --from=build-env /app/output/wwwroot/ .

over 4 years ago · Santiago Trujillo Denunciar

0

I got the same issue and fixed it by removing the white spaces from before and after "events" and "http", so my config file become:

events{}
http{
    include mime.types;
types {
    application/wasm wasm;
}

server {
    listen 80;

    # Here, we set the location for Nginx to serve the files
    # by looking for index.html
    location / {
        root /usr/local/webapp/nginx/html;
        try_files $uri $uri/ /index.html =404;
    }
}
}
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda