• 通过Nginx发布React


    0、写在前面

    最近项目需要用到nginx发布react,记录一下

    1、react

    npm run-script build 生成build文件夹

    2、nginx

    复制build文件夹到nignx的html文件夹中

     1     server {
     2         listen       80;
     3         listen    [::]:80;
     4         server_name  localhost;
     5 
     6         #charset koi8-r;
     7 
     8         #access_log  logs/host.access.log  main;
     9 
    10         location / {
    11             root   html/build;
    12             #index  index.html index.htm;
    13         try_files $uri /index.html;
    14         }
    15 
    16 
    17         location ^~ /api/ws/ {
    18             proxy_pass http://61.6.192.148:8001/ws/;
    19             proxy_http_version 1.1;
    20             proxy_set_header Upgrade $http_upgrade;
    21             proxy_set_header Connection "Upgrade";
    22             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    23         }
    24 
    25         location /api/ {
    26             proxy_set_header Host $host;
    27             proxy_set_header X-Real-IP $remote_addr;
    28             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    29             proxy_pass http://61.6.192.148:8001/;
    30         }
    31     
    32         location = /50x.html {
    33             root   html;
    34         }
    35 
    36     }

    日常维护:

    1、git上传

    //查看状态
    git status
    //添加该项目下的所有文件
    git add .
    //使用如下命令将文件添加到本地仓库中去
    git commit -m "添加了些新的测试模块"
    //推送到远程库
    git push -u origin master
  • 相关阅读:
    Github markdown页面内跳转
    github gist 无法访问
    Install pyaudio on Ubuntu
    删除链表的倒数第N个节点
    电话号码的字母组合
    最长公共前缀
    盛最多水的容器
    字符串转化整数与回文数
    Z 字形变换
    LeetCode1-5题
  • 原文地址:https://www.cnblogs.com/cx59244405/p/14863404.html
Copyright © 2020-2023  润新知