• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Resolved react on nginx page refresh leads to 404

mathi_reg

Basic Pleskian
Hey guys,

I found a little bit online but not the solution to my problem yet.

I'm working on a react native app that is also working as website. All permalinks/urls of the app work just fine and everything checks out. Only problem. When on example.com/something/something and I refresh the page it always results in a 404 page.

What I tried now

I ssh'ed into /var/www/vhosts/system/mydomain.com/conf and udpated the file nginx.conf with


Code:
server {
       location / {
               try_files $uri $uri/ /index.html?$query_string;
       }
}


I restarted the service, however this does not do the trick.

Any idea how to fix that?

Thanks Matt

Here is the full nginx.conf file:

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;
       }
}
 
Back
Top