title: React-router and nginx
body: <p>I am transitioning my react app from webpack-dev-server to nginx.</p>
  
  <p>When I go to the root url "localhost:8080/login" I simply get a 404 and in my nginx log I see that it is trying to get:</p>
  
  <pre><code>my-nginx-container | 2017/05/12 21:07:01 [error] 6#6: *11 open() "/wwwroot/login" failed (2: No such file or directory), client: 172.20.0.1, server: , request: "GET /login HTTP/1.1", host: "localhost:8080"
  my-nginx-container | 172.20.0.1 - - [12/May/2017:21:07:01 +0000] "GET /login HTTP/1.1" 404 169 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101 Firefox/53.0" "-"
  </code></pre>
  
  <p>Where should I look for a fix ?</p>
  
  <p>My router bit in react looks like this:</p>
  
  <pre><code>render(
  
    &lt;Provider store={store}&gt;
      &lt;MuiThemeProvider&gt;
        &lt;BrowserRouter history={history}&gt;
          &lt;div&gt;
            Hello there p
            &lt;Route path="/login" component={Login} /&gt;
            &lt;App&gt;
  
              &lt;Route path="/albums" component={Albums}/&gt;
  
              &lt;Photos&gt;
                &lt;Route path="/photos" component={SearchPhotos}/&gt;
              &lt;/Photos&gt;
              &lt;div&gt;&lt;/div&gt;
              &lt;Catalogs&gt;
                &lt;Route path="/catalogs/list" component={CatalogList}/&gt;
                &lt;Route path="/catalogs/new" component={NewCatalog}/&gt;
                &lt;Route path="/catalogs/:id/photos/" component={CatalogPhotos}/&gt;
                &lt;Route path="/catalogs/:id/photos/:photoId/card" component={PhotoCard}/&gt;
              &lt;/Catalogs&gt;
            &lt;/App&gt;
          &lt;/div&gt;
        &lt;/BrowserRouter&gt;
      &lt;/MuiThemeProvider&gt;
    &lt;/Provider&gt;, app);
  </code></pre>
  
  <p>And my nginx file like this:</p>
  
  <pre><code>user  nginx;
  worker_processes  1;
  
  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 8080;
          root /wwwroot;
  
          location / {
              root /wwwroot;
              index index.html;
  
              try_files $uri $uri/ /wwwroot/index.html;
          }
  
  
      }
  }
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I know that most of the setup works because when I go to localhost:8080 without being logged in I get the login page as well. this is not through a redirect to localhost:8080/login - it is some react code.</p>