我'm trying to deploy my meteor server on my debian server. I'使用nginx并永远运行捆绑的流星应用程序 . (我按照以下教程:https://medium.com/startup-founder-panel/deploying-a-meteor-app-with-nginx-from-scratch-1332b32e99a5)
它适用于服务器部分(我正在连接一个反应本机的应用程序,它工作正常),但它不适用于React Web客户端部分:
它说它无法加载js和css文件,就像那些无法从客户端访问的文件一样,尽管它们实际上存在于我的linux服务器的捆绑文件夹中 .
这里的错误是什么样的:
GET http://example.com/ea63eb5bb7607b3ce74dca13734da44296043bb9.css?meteor_css_resource=true 404 (Not Found)
GET http://example.com/051b222361019ff9f7996039dc35fb4902c12405.js?meteor_js_resource=true 404 (Not Found)
这是index.html包含的内容:
这是用于构建/清理流星的脚本:
meteor npm install
npm prune --production
rm -rf ~/bundle #Remove the previous bundle
rm -rf ~/portal
meteor --allow-superuser build --directory ~
cd ~/bundle/programs/server #Enter the bundle
npm install
mv ~/bundle ~/portal
mkdir ~/logs
# Use forever to start the Node server
export PORT=8080
export MONGO_URL='mongodb+srv://user:password@url'
export ROOT_URL='http://example.com'
export METEOR_SETTINGS='{ <fiew settings> }'
#export MAIL_URL='smtp://user:password@mailhost:port/'
cd ~/portal
forever stop main.js
forever start -a -l ~/logs/forever.log -o ~/logs/portal.out -e ~/logs/portal.err main.js
这是我的流星应用程序的nginx配置:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
#HTTP
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
location = /favicon.ico {
root /root/portal/programs/web.browser/app;
access_log off;
}
location ~* "^/[a-z0-9]{40}\.(css|js).*$" {
gzip_static on;
root /root/portal/programs/web.brower;
access_log off;
}
location ~"^/packages" {
root /root/portal/programs/web.browser;
access_log off;
}
# pass requests to Meteor
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; #for websockets
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
我知道我错过了一些东西,所以客户端可以看到两个css和js文件,但在一天的尝试后我找不到任何东西 .
非常感谢能解锁我的那个!