KillThunder
V2EX  ›  问与答

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

  •  
  •   KillThunder · Nov 11, 2017 · 1965 views
    This topic created in 3177 days ago, the information mentioned may be changed or developed.

    我最近在学习 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 replies    2017-11-11 15:35:19 +08:00
    isCyan
        1
    isCyan  
       Nov 11, 2017 via Android
    伸手党,又没有日志,光贴配置有什么用。
    再说了问题不一定在 nginx 上啊,后端程序有没有启动啊,后端端口有没有正确地被监听啊。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4615 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 09:50 · PVG 17:50 · LAX 02:50 · JFK 05:50
    ♥ Do have faith in what you're doing.