• nignx部署系统刷新页面nignx404


    server {
            listen       80;
            server_name  localhost;
            
            location / {
               root   D:/workspace/ccsa-check/ccsa-ui/dist;
               index  index.html;
               try_files  $uri $uri/ /index.html;
            }
    
           location /prod-api/ {
               proxy_pass   http://localhost:8080/;
            }
    }

    添加 try_files $uri $uri/ /index.html;

    在配置中加上try_files,意思跟翻译差不多,“尝试读取文件”。u r i 这 个 是 n g i n x 的 一 个 变 量 , 存 放 着 用 户 访 问 的 地 址 , 例 如 h t t p : / / l o c a l h o s t : 8200 / c h o o s e S i z e 那 么 uri 这个是nginx的一个变量,存放着用户访问的地址,例如http://localhost:8200/chooseSize 那么uri这个是nginx的一个变量,存放着用户访问的地址,例如http://localhost:8200/chooseSize那么uri就是/chooseSize;u r i / 代 表 访 问 的 是 一 个 目 录 例 如 h t t p : / / l o c a l h o s t : 8200 / c h o o s e S i z e / 那 么 uri/ 代表访问的是一个目录 例如http://localhost:8200/chooseSize/ 那么uri/代表访问的是一个目录例如http://localhost:8200/chooseSize/那么uri/就是/chooseSize/;最后/index.html就是我们首页的地址。
    最终上面的意思是如果第一个存在,直接返回;不存在的话读取第二个,如果存在,读取返回;如果还是不存在,就会fall back到 try_files 的最后一个选项 /index.html,发起一个内部 “子请求”,也就是相当于 nginx 发起一个 HTTP 请求到

  • 相关阅读:
    计算GPS WGS_84 两点的距离
    极路由4_开ssh_刷breed
    aes-256-gcm_python3_php7_golang
    nginx_非标准端口_同端口_http_自动跳转_https
    配置sshd_除了特定ip外_仅密钥登录
    使用scp命令实现服务器之间文件传输
    Java防止重复提
    mysql使用SUBSTRING_INDEX截取部分字符串
    SEO大杀器rendertron安装
    PIC16 bootloader之I2C bootloader
  • 原文地址:https://www.cnblogs.com/wang66a/p/16317597.html
Copyright © 2020-2023  润新知