找不到“ pm2服务构建端口”回声404

时间:2018-09-18 00:39:03

标签: javascript node.js reactjs pm2 serve

我已经完成了本教程,

https://reactjs.org/tutorial/tutorial.html

然后将其上传到生产服务器,该服务器在具有SSL的ubuntu nginx上运行。运行npm run build,创建构建文件,并使用serve module serve -s -p 8083 build提供静态文件。它在端口8083上运行正常。

但是当我尝试将其添加为pm2服务pm2 serve ./build/ 8083时,会得到 404未找到(当它未运行时,错误是502 Bad Gateway) >

我尝试了几种方法,例如pm2 serve ./ 8083pm2 serve ./public/ 8083等。

Nginx配置:

    location ~* /.(js|jpg|png|css)$ {
     access_log off;
     expires max;
    }
    location = /react-game {
    root /var/www/test.com/html/react-game/build;
    proxy_pass http://localhost:8083;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    autoindex off;
    }

有什么想法如何将pm2复制serve -s -p 8083 build吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

我认为主要的问题是df <- data.frame(ID=1:3, Week_A=c(6,6,7), Weight_A=c(23,24,23), Week_B=c(7,7,8), Weight_B=c(25,26,27), Week_C=c(8,9,9), Weight_C=c(27,26,28)) library(tidyverse) df_long <- df %>% gather(key="v", value="value", -ID) %>% separate(v, into=c("v1", "v2")) %>% spread(v1, value) %>% complete(ID, Week) %>% arrange(Week, ID) df_long # A tibble: 12 x 4 # ID Week v2 Weight # <int> <dbl> <chr> <dbl> # 1 1 6 A 23 # 2 2 6 A 24 # 3 3 6 <NA> NA # 4 1 7 B 25 # 5 2 7 B 26 # 6 3 7 A 23 # 7 1 8 C 27 # 8 2 8 <NA> NA # 9 3 8 B 27 #10 1 9 <NA> NA #11 2 9 C 26 #12 3 9 C 28 df_wide <- df_long %>% select(-v2) %>% spread(Week, Weight, sep="_") df_wide # A tibble: 3 x 5 # ID Week_6 Week_7 Week_8 Week_9 # <int> <dbl> <dbl> <dbl> <dbl> #1 1 23 25 27 NA #2 2 24 26 NA 26 #3 3 NA 23 27 28 是要提供静态文件,而tidy是要持久运行脚本。这是有关与pm2互动的文章:

https://ygamretuta.xyz/deploy-create-react-app-with-pm2-16beb90ce52

但是,您是否有理由不想让nginx监听端口8083并单独静态地提供构建文件?还是有一个原因您没有在端口80上提供构建文件?