配置1

    1. server{
    2. listen 80;
    3. server_name www.gejialun.vip;
    4. index index.html;
    5. error_log /www/wwwlogs/nginx/error.log;
    6. access_log /www/wwwlogs/nginx/access.log;
    7. location / {
    8. root /www/wwwroot/web_site/build; # 网站根目录
    9. index index.html; # 默认首页文件
    10. try_files $uri $uri/ /index;
    11. }
    12. # location /vite2-vue3-jsx {
    13. # alias /www/wwwroot/vite2-vue3-jsx; # 网站根目录
    14. # index index.html; # 默认首页文件
    15. # try_files $uri $uri/ /index;
    16. # }
    17. # location /vite2-react17 {
    18. # alias /www/wwwroot/vite2-react17; # 网站根目录
    19. # index index.html; # 默认首页文件
    20. # try_files $uri $uri/ /index;
    21. # }
    22. }

    配置2

    1. server {
    2. listen 80;
    3. server_name reactchart.gejialun.vip;
    4. location / {
    5. root /www/wwwroot/react-chart; # 项目打包后的文件夹
    6. index index.html index.htm;
    7. try_files $uri $uri/ /index.html @rewrites;
    8. expires -1; # 首页一般没有强制缓存
    9. add_header Cache-Control no-cache;
    10. }
    11. location @rewrites {
    12. rewrite ^(.+)$ /index.html break;
    13. }
    14. }