title: react, nginx reverse proxy and docker giving 404
body: <p>So my website has two parts:</p>
  <p>1- /api, /oauth and /assets locations are redirected to a laravel app and using a simple proxy_pass to their docker port</p>
  <p>2- the web app, which is a react app. We make an image of the web app(so no files are transferred to the server) and run it on a port, say 3000.</p>
  <p>This is a summary of my Nginx configuration:</p>
  <pre><code>server {
          server_name mywebsite.com;
  
          location /api {
                  proxy_pass http://localhost:8080/api;
                  proxy_set_header Host $host;
          } //the same with other Laravel paths
  
          location / {
                  proxy_pass http://localhost:3000/;
                  proxy_set_header Host $host;
                  proxy_redirect off;
          }
  }
  </code></pre>
  <p>The problem is if the user goes to a page, say site.com/profile and refreshes it, they get a 404 error. Googling a lot resulted to use <code>try_files .. index.html</code> which works with local files, but not when using proxy_pass and docker images.</p>
  <p>More googling had me find a solution that actually worked:</p>
  <pre><code>server {
          server_name mywebsite.com;
  
          location /api {
                  proxy_pass http://localhost:8080/api;
                  proxy_set_header Host $host;
          } //the same with other Laravel paths
  
          location / {
                  proxy_pass http://localhost:3000/;
                  proxy_set_header Host $host;
                  proxy_redirect off;
                  proxy_intercept_errors on;
                  recursive_error_pages on;
                  error_page 404 = @rewrite_proxy;
          }
  
          location @rewrite_proxy {
                  rewrite ^/(.*)$ /index.html?$1 break;
                  proxy_pass http://localhost:3000;
                  proxy_set_header Host $host;
          }
  }
  </code></pre>
  <p>It's brilliant and works like a charm. Now the problem is, I'm looking for a solution to give control of ACTUAL 404 errors to the web app, so it can react in different ways depending on the URL. Any suggestions?</p>