使用Ubuntu,我用Spring和MySQL上传了后端。
java -jar hi-0.0.1-SNAPSHOT.jar没有错误,它看起来很好(Tomcat初始化了端口: 8000 (http))
接下来我安装了Nginx。然后,我在React中执行了npm build,并通过Filezilla将构建文件夹传输到/home。
在我的/etc/nginx/sites-available中,我创建了一个myapp.conf文件,并使用
server {
listen 80;
location / {
root /home/build;
index index.html index.htm;
try_files $uri $uri/ /index.html;
proxy_pass http://localhost:8000;
}}sudo ln -s /etc/nginx/sites-available/myapp.conf /etc/nginx/sites-enabled/myapp.conf如果我删除了proxy_pass http://localhost:8000,那么React就会显示其内容,而不会出现错误。
然而,我似乎不能得到弹簧启动和反应联系。如果我使用proxy_pass或任何其他方法,我会得到502个坏网关错误。我安装了MySQL服务器、JDK、NPM、Node.js。还有需要安装或编辑的地方吗?
发布于 2022-07-30 07:01:36
下面的链接给出了NGinx中react应用程序的明确部署步骤。
https://dev.to/xarala221/the-easiest-way-to-deploy-a-react-web-application-2l8a
另外,你能更详细地解释一下这个问题吗?
如果您单独测试基于Spring的web服务,它们是否正常工作?要从连接到REST,可以使用npm axios包。
https://stackoverflow.com/questions/73138927
复制相似问题