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

2.1K
Vistas
Angular, Nginx, Docker da como resultado un error 404 al actualizar la página

Tengo una aplicación angular y uso nginx en el contenedor docker. Cuando ejecuto la aplicación, el localhost funciona bien y se redirige a localhost/auth pero cuando actualizo el navegador con localhost/auth en la dirección, aparece el error 404. Seguí otros foros como 404 Error al actualizar la página con Angular 7 , NGINX y Docker , Angular Nginx Docker 404 también, pero aún existe el mismo problema.

DockerFile

 FROM node:alpine as builder WORKDIR /app # Install app dependencies COPY . /app/ RUN cd /app && yarn install RUN cd /app && yarn build:aot:dev COPY ./nginx.conf /etc/nginx/nginx.conf # STEP 2 build a small nginx image with static website FROM nginx:alpine COPY ./nginx.conf /etc/nginx/nginx.conf RUN rm -rf /usr/share/nginx/html/* COPY --from=builder /app/dist/apps/martor /usr/share/nginx/html RUN ls /usr/share/nginx/html EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]

nginx.conf

 user nginx; worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; gzip on; include /etc/nginx/conf.d/*.conf; server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; error_page 403 404 /index.html; location / { root /usr/share/nginx/html; try_files $uri $uri/ index.html; index index.html index.html; # Allo CORS if ($request_method ~* "(GET|POST|PUT|DELETE|PATCH|OPTIONS)") { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE, PUT, PATCH, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Content-Type, x-access-token,access-control-allow-origin,access-control-allow-credentials,access-control-allow-headers'; add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range'; } } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } } }
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Creo que olvida el /index.html (observe el '/') en la línea try_files. Entonces, al acceder a localhost/auth, nginx intenta resolver /usr/share/nginx/html/auth/index.html en lugar de /usr/share/nginx/html/index.html .

Intenta reemplazar

 try_files $uri $uri/ index.html;

por

 try_files $uri $uri/ /index.html;
over 4 years ago · Santiago Trujillo Denunciar

0

El problema se resuelve agregando páginas de error en el frente de la nube de aws CDN

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