前段时间,我在 Centos7 上用 Nginx 和 Supervisord 部署了一个 Meteor 应用程序。它工作正常,这是配置文件:
nginx.conf:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://localhost:3003/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
}
}
supervisord.conf:
[program:monitoring]
command=node main.js ; the program (relative uses PATH, can take args)
directory=/home/[email protected]/bundle
process_name=%(program_name)s ; process_name expr (default %(program_name)s)
numprocs=1 ; number of processes copies to start (def 1)
autostart=true ; start at supervisord start (default: true)
autorestart=unexpected ; whether/when to restart (default: unexpected)
;user=app_user ; setuid to this UNIX account to run the program
redirect_stderr=true ; redirect proc stderr to stdout (default false)
stdout_logfile=/var/log/meteor.log ; stdout log path, NONE for none; default AUTO
stdout_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=10 ; # of stdout logfile backups (default 10)
;stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stdout_events_enabled=false ; emit events on stdout writes (default false)
stderr_logfile=/var/log/meteor_err.log ; stderr log path, NONE for none; default AUTO
stderr_logfile_maxbytes=1MB ; max # logfile bytes b4 rotation (default 50MB)
stderr_logfile_backups=10 ; # of stderr logfile backups (default 10)
;stderr_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
;stderr_events_enabled=false ; emit events on stderr writes (default false)
environment=MONGO_URL="mongodb://<username>:<password>@localhost:27017/monitoring" ; process environment additions (def no adds)
问题
今天我想在这台服务器上放另一个应用程序。为此,我尝试更改我的第一个流星应用程序的位置,正如许多教程所说:
location /monitoring/ {
proxy_pass http://localhost:3003/;
...
}
但我收到一个 50 倍的错误:
> [error] 23284#0: *8 connect() failed (111: Connection refused) while connecting to upstream, client: 10.20.3.135, server: _, request: "GET /monitoring/monitoringboard HTTP/1.1", upstream: "http://127.0.0.1:3003/monitoringboard", host: "10.20.3.249
有人有建议吗?谢谢
我终于找到了解决方案。
nginx.config:
location /monitoring {
proxy_pass http://localhost:3003;
...
}
supervisord.confg:
[program:monitoring]
....
environment=PORT="3003,ROOT_URL="http://10.20.3.249/monitoring", MONGO_URL="mongodb://<username>:<password>@localhost:27017/monitoring"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句