title: nginx: react native url refresh leads to 404
body: <p>also after googling quite a bit I was not able to find the solution. I'm running a Plesk for Ubuntu and am currently deploying a react native app. All url-paths checkout fine and navigation within the app works. However if I'm for instance on www.mydomain.com/something/something and I refresh the page the refresh leads to a 404 error.</p>
  
  <p>What I tried now</p>
  
  <p>I ssh'ed into <code>/var/www/vhosts/system/mydomain.com/conf</code> and udpated the file <code>nginx.conf</code> with</p>
  
  <pre><code>server {
          location / {
                  try_files $uri $uri/ /index.html?$query_string;
          }
  }
  </code></pre>
  
  <p>I restarted the service, however this does not do the trick. </p>
  
  <p>Any idea how to fix that?</p>
  
  <p>Thanks
  Matt</p>
  
  <p>Here is the full nginx.conf file:</p>
  
  <pre><code>#ATTENTION!
  #
  #DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
  #SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.
  
  server {
          listen 175.31.15.213:443 ssl http2;
  
          server_name example.com;
          server_name www.example.com;
          server_name ipv4.example.com;
          server_name "example.com.52-29-213-14.svr.fm";
  
          ssl_certificate             /opt/psa/var/certificates/certXTrwD4;
          ssl_certificate_key         /opt/psa/var/certificates/certXTrwD4;
          ssl_client_certificate      /opt/psa/var/certificates/certL2SKRF;
  
          client_max_body_size 128m;
  
          root "/var/www/vhosts/example.com/httpdocs";
          access_log "/var/www/vhosts/system/example.com/logs/proxy_access_ssl_log";
          error_log "/var/www/vhosts/system/example.com/logs/proxy_error_log";
  
          if ($host ~* ^1519\.tirol$) {
                  rewrite ^(.*)$ https://www.example.com$1 permanent;
          }
  
          #extension letsencrypt begin
          location ^~ /.well-known/acme-challenge/ {
                  root /var/www/vhosts/default/htdocs;
  
                  types { }
                  default_type text/plain;
  
                  satisfy any;
                  auth_basic off;
                  allow all;
  
                  location ~ ^/\.well-known/acme-challenge.*/\. {
                          deny all;
                  }
          }
  
          #extension letsencrypt end
  
          location / {
                  proxy_pass https://175.31.15.213:7081;
                  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-Accel-Internal /internal-nginx-static-location;
                  access_log off;
  
          }
  
          location /internal-nginx-static-location/ {
                  alias /var/www/vhosts/example.com/httpdocs/;
                  internal;
          }
  
          location ~ ^/(plesk-stat|awstats-icon|webstat|webstat-ssl|ftpstat|anon_ftpstat) {
                  proxy_pass https://175.31.15.213:7081;
                  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-Accel-Internal /internal-nginx-static-location;
                  access_log off;
  
          }
  
          location /internal-nginx-static-location/ {
                  alias /var/www/vhosts/example.com/httpdocs/;
                  internal;
          }
  
          location ~ ^/(plesk-stat|awstats-icon|webstat|webstat-ssl|ftpstat|anon_ftpstat) {
                  proxy_pass https://175.31.15.213:7081;
                  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-Accel-Internal /internal-nginx-static-location;
                  access_log off;
  
          }
  
          location ~ ^/~(.+?)(/.*?\.php)(/.*)?$ {
                  alias /var/www/vhosts/example.com/web_users/$1/$2;
                  fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
                  fastcgi_param PATH_INFO $fastcgi_path_info;
                  fastcgi_pass "unix:///var/www/vhosts/system/example.com/php-fpm.sock";
                  include /etc/nginx/fastcgi.conf;
  
          }
  
          location ~ ^/~(.+?)(/.*)?$ {
                  proxy_pass https://175.31.15.213:7081;
                  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-Accel-Internal /internal-nginx-static-location;
                  access_log off;
          }
  
          location ~ \.php(/.*)?$ {
                  fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
                  fastcgi_param PATH_INFO $fastcgi_path_info;
                  fastcgi_pass "unix:///var/www/vhosts/system/example.com/php-fpm.sock";
                  include /etc/nginx/fastcgi.conf;
  
          }
  
          location ~ /$ {
                  index "index.html" "index.cgi" "index.pl" "index.php" "index.xhtml" "index.htm" "index.shtml";
          }
  
          add_header X-Powered-By PleskLin;
  
          include "/var/www/vhosts/system/example.com/conf/vhost_nginx.conf";
  }
  
  server {
          listen 175.31.15.213:80;
  
          server_name example.com;
          server_name www.example.com;
          server_name ipv4.example.com;
          server_name "example.com.52-29-213-14.svr.fm";
  
          client_max_body_size 128m;
  
          if ($host ~* ^1519\.tirol$) {
                  rewrite ^(.*)$ https://www.example.com$1 permanent;
          }
  
          return 301 https://$host$request_uri;
  }
  
  server {
          location / {
                  try_files $uri $uri/ /index.html?$query_string;
          }
  }
  </code></pre>