2017-08-02 166 views
1

很久以前,我在Centos7上用Nginx和Supervisord部署了一个Meteor应用程序。它工作正常,这里有CONFIGS文件:Nginx - 多个应用程序

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 

有人有一个建议?谢谢

回答

0

我终于找到解决办法。

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"