V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
KillThunder
V2EX  ›  问与答

关于 Nginx 负载均衡的配置问题

  •  
  •   KillThunder · 2017-11-11 14:41:51 +08:00 · 1312 次点击
    这是一个创建于 2358 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我最近在学习 Nginx,想配置一下 Nginx 的负载均衡,在同一台机器上启动了两个 tomcat,但使用 localhost 访问时报错:502 Bad Gateway。求 v 友帮忙看一下问题出在哪里?一下是我的配置文件:
    user www-data; worker_processes 4; pid /run/nginx.pid;

    events { worker_connections 768;
    # multi_accept on;
    }

    http { upstream test_A {
    server 127.0.0.1:8000;
    server 127.0.0.1:8001;
    }

        server {
                listen 80;
                server_name localhost;
                location / {
                #       proxy_pass http://127.0.0.1:8080;
                        proxy_pass http://test_A;
                #       index home.html;
                }
        }
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;
    
        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;
    
        include /etc/nginx/mime.types;
        default_type application/octet-stream;
    
        ##
        # Logging Settings
        ##
    
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        gzip on;
        gzip_disable "msie6";
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
    

    }

    1 条回复    2017-11-11 15:35:19 +08:00
    isCyan
        1
    isCyan  
       2017-11-11 15:35:19 +08:00 via Android
    伸手党,又没有日志,光贴配置有什么用。
    再说了问题不一定在 nginx 上啊,后端程序有没有启动啊,后端端口有没有正确地被监听啊。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1483 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 17:37 · PVG 01:37 · LAX 10:37 · JFK 13:37
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.