Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

2.1K
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!