Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

2.1K
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda