nginx:反应本机URL刷新导致404

时间:2019-06-07 07:12:53

标签: react-native nginx http-status-code-404

在搜索了很多之后,我也找不到解决方案。我正在为Ubuntu运行Plesk,目前正在部署React本机应用程序。应用程序中的所有url路径都可以正常检出和导航。但是,例如,如果我在www.mydomain.com/something/something上,并且刷新页面,刷新将导致404错误。

我现在尝试了什么

我将其缩进/var/www/vhosts/system/mydomain.com/conf中,并用{p>替换文件nginx.conf

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

我重新启动了服务,但是并不能解决问题。

有什么办法解决吗?

谢谢 马特

这是完整的nginx.conf文件:

#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;
        }
}

0 个答案:

没有答案