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

593
Views
Nginx routing not working when refresh page or when I go directly to the page

I'm running Docker Containers with a Vue.js front and a Node.js+Express.js backend and managing the routes using Nginx.

When I access the route https://equilibrista.app/ and click the link inside the page to go to https://equilibrista.app/exams it works fine, but I got an error when I directly goes to this page (and a Express error shows up Cannot GET /exams).

link to /exams page

Why is this happening? It looks like an Nginx redirect error, but I couldn't find anything wrong on nginx.conf

server {
  listen 80;
  listen [::]:80;
  server_name equilibrista.app www.equilibrista.app;

  location ~ /.well-known/acme-challenge {
    allow all;
    root /var/www/html;
  }

  location / {
    rewrite ^ https://$host$request_uri? permanent;
  }
}

server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;
  server_name equilibrista.app www.equilibrista.app;

  server_tokens off;

  ssl_certificate /etc/letsencrypt/live/equilibrista.app/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/equilibrista.app/privkey.pem;

  ssl_buffer_size 8k;

  ssl_dhparam /etc/ssl/certs/dhparam-2048.pem;

  ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
  ssl_prefer_server_ciphers on;

  ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

  ssl_ecdh_curve secp384r1;
  ssl_session_tickets off;

  ssl_stapling on;
  ssl_stapling_verify on;
  resolver 8.8.8.8;

  location /api/ {
    proxy_pass http://api:3000/;
    proxy_redirect off;
  }

  location / {
    proxy_pass http://front:8888;
  }
}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The way we got it to work with a Vue app was following.

1) First you have a location that capture all the physical files and paths that exists.

2) Secondly you redirect any other request to the main application file, for Vue it is index.html.

So your location configuration should look like this:

location /api/ { 
    proxy_pass http://api:3000/; 
} 

location ~* \/(index\.html|favicon\.ico|styles\.css|styles\.min\.css|css\/.*|js\/.*|images\/.*) {
    proxy_pass http://front:8888;
} 

location / { 
    rewrite / /index.html; 
    proxy_pass http://front:8888;
} 

(updated to match question)

we have the static files on the nginx server, but it should work the same way with proxy_pass.

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!