Nginx Resource not found on refresh with React router

Viewed 285

I am running a React app on Nginx in production.

If I refresh on any route different that "/" I get "Resource not found".

for example:

Refresh on http://www.aaaa.com will be OK

Refresh on http://www.aaaa.com/bbb/ddd will result in Resource not found.

I searched a lot and tried everything I found including adding try_files $uri $uri/ /index.html;

This is part of my conf file:

  upstream ggg_stream {
    server ggg.aaa.com:9090 fail_timeout=0;
  }

  server {

    listen 80;
    server_name aaa.com;
    root /var/www;

    location / {
      try_files $uri $uri/ /index.html;
    }

    location /ggg {

      proxy_set_header        Host $host;
      proxy_set_header        X-Real-IP $remote_addr;
      proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header        X-Forwarded-Proto $scheme;

      # Fix the "It appears that your reverse proxy set up is broken" error.
      proxy_pass          http://ggg_stream/;
      proxy_read_timeout  90;

     #  proxy_redirect      http://127.0.0.1:8080 http://34.248.183.236:8080;

      # Required for new HTTP-based CLI
      proxy_http_version 1.1;
      proxy_request_buffering off;
    } 
  }

This server also used as a proxy so it has many stream mappings such as ggg The site content is located at /var/www We use React router 4.

Any ideas?

Regards, Ido

0 Answers
Related