Nginx - 多个应用程序

本杰明·卢西达姆

前段时间,我在 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Rails Nginx:多个应用程序

使用Nginx部署多个Go应用程序

为多个Rails应用程序配置NGINX

具有多个symfony2应用程序的nginx

在多个Nginx位置的龙卷风应用程序

Nginx 反向代理多个 React 应用程序

在Nginx中使用多个应用程序获取DNS映射

Nginx具有多个子域的多个节点应用程序

Nginx:在同一服务器上服务多个React应用程序

是否可以在单个 NGINX 容器中托管多个 Web 应用程序容器?

NGINX-PHP-FPM多个应用程序K8s /入口

使用Nginx + Unicorn在子文件夹上托管多个Rails应用程序

使用Nginx和Unicorn的多个Rails应用程序的一个域名

使用docker的多个nginx / php应用程序的体系结构

如何在Nginx上托管的单个域下托管多个Flask应用程序?

没有Nginx的Puma-同一IP:PORT上的多个ruby应用程序

使Nginx为节点应用程序服务多个虚拟服务器

如何托管多个 Angular 应用程序,使用 nginx 容器进行子域

用nginx代理jboss应用程序

Nginx单个应用程序配置

使用NginX服务角度应用程序

使用Nginx映射Rails应用程序

从一台Nginx服务器提供多个单页应用程序的多个版本?

Nginx拒绝与Flask应用程序的连接,没有Nginx的Flask应用程序工作正常

使用Nginx运行守护程序的Bottle应用程序

NGINX:使用域/路径在同一服务器上的多个节点js应用程序

nginx 上的不同路径映射 php-fpm 用于构建同一应用程序的多个变体

在 Ubuntu 14.04 可信服务器上使用 nginx 和 gunicorn 的多个 Django 应用程序

我如何在Nginx服务器上运行多个asp.net核心应用程序