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

2017-11-11 14:41:51 +08:00
 KillThunder

我最近在学习 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/*;

}

1317 次点击
所在节点    问与答
1 条回复
isCyan
2017-11-11 15:35:19 +08:00
伸手党,又没有日志,光贴配置有什么用。
再说了问题不一定在 nginx 上啊,后端程序有没有启动啊,后端端口有没有正确地被监听啊。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/405536

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX