Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

tomcat - Testing load balancing in NGINX

I set up load balancing on NGINX using the Round Robin for apache tomcat servers with two servers in my proxy.conf file:

upstream appcluster1 {
    server IP_ADDRESS:8000;
    server IP_ADDRESS:8001;
}

server {
    location / {
        proxy_pass http://appcluster1;
    }

}

This is deployed on the cloud and I am able to hit the endpoint using this method successfully. However, I want to test and see if nginx redirects between the two servers. How would I go about this?

I tried this method but I do not see anything in the logs that shows what server it is hitting. Is there any other way I can test and see if nginx would go to the second server?

EDIT: I have another file called nginx.conf that looks like this:

load_module modules/ngx_http_js_module.so;
user nginx;
worker_processes auto;

events {
    worker_connections 2048;
}

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;
    js_include auth.js;
    proxy_buffering off;

    log_format upstreamlog '$server_name to: $upstream_addr {$request} '
    'upstream_response_time $upstream_response_time'
    ' request_time $request_time';
    # log_format   main '$remote_addr - $remote_user [$time_local]  $status '
    # '"$request" $body_bytes_sent "$http_referer" '
    # '"$http_user_agent" "$http_x_forwarded_for"';

    # access_log   logs/access.log  main;
    # sendfile     on;
    #tcp_nopush   on;

    keepalive_timeout  65s;
    proxy_connect_timeout 120s; 
    keepalive_requests 50;
    include /etc/nginx/conf.d/*.conf;
}
question from:https://stackoverflow.com/questions/65946390/testing-load-balancing-in-nginx

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...