zoukankan      html  css  js  c++  java
  • 通过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
  • 相关阅读:
    nginx重启命令
    Java中Vector笔记
    JAVA中字符串比较equals()和equalsIgnoreCase()的区别
    HashMap和TreeMap的常用排序方法
    Logger用法
    HashMap和Hashtable的区别
    class.getDeclaredFields()与class.getFields()
    java中 文件压缩处理
    Java远程执行Shell命令
    python 学习笔记 redis操作
  • 原文地址:https://www.cnblogs.com/cx59244405/p/14863404.html
Copyright © 2011-2022 走看看