开发者社区> 问答> 正文

nginx负载均衡问题

负载均衡配置后,可以访问前台页面,但是输入用户名密码后闪一下就没了。

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

#keepalive_timeout  0;
keepalive_timeout  65;

#gzip  on;
# Load config files from the /etc/nginx/conf.d directory
# The default server is in conf.d/default.conf
# include /etc/nginx/conf.d/*.conf;
 upstream tomcats{
    server 192.168.42.128:8080;
    server 192.168.42.129:8080;
     }
server
{
listen 80;
server_name 192.168.42.130;
location / {
proxy_pass http://tomcats;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}

展开
收起
蛮大人123 2016-06-03 14:30:37 2752 0
4 条回答
写回答
取消 提交回答
  • 软件开发,安全加密

    测试一个tomcat试试

    2019-07-17 19:26:36
    赞同 展开评论 打赏
  • 没会话保持吧

    2019-07-17 19:26:36
    赞同 展开评论 打赏
  • upstream 可以加入session_sticky参数

    2019-07-17 19:26:36
    赞同 展开评论 打赏
  • 我说我不帅他们就打我,还说我虚伪

    请在upsteam 里加入参数ip_hash.

    2019-07-17 19:26:36
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
大规模场景下KubernetesService 负载均衡性能 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载