How does nginx integrate Shiro and redis in SpringBoot to configure session sharing

first of all:

When we deploy projects, we sometimes need cluster deployment to ensure that a single platform can continue to provide services to users after a single platform is offline, to ensure our online business, so we need nginx clusters to deploy. In this way, it can be ensured that after a server goes down, the online business will not cause us losses.

In the last article, we have cached the session in redis. Here we only need to configure the same nginx for three machines. Read the same session.

For the window system used by the author here, the nginx version can be higher, and there are too many problems with the lower version.

Not much to say, the content of the nginx.conf file is as follows

worker_processes  8;

events {
    worker_connections  8192;
}

http {
    include       mime.types;
	include		  conf.d/lfs.conf;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;
	underscores_in_headers on;
	
	#主服务
	upstream rs {
        server 127.0.0.1:8635 weight=10;
        server 127.0.0.1:8636 weight=10;
        server 127.0.0.1:8637 weight=10;
        server 127.0.0.1:8638 weight=10;
        server 127.0.0.1:8639 weight=10;
        server 127.0.0.1:8640 weight=10;
        server 127.0.0.1:8641 weight=10;
        server 127.0.0.1:8642 weight=10;
        server 127.0.0.1:8643 weight=10;
        server 127.0.0.1:8644 weight=10;
	}
	
	upstream fm {
		server 127.0.0.1:8086 weight=10;
		server 127.0.0.1:8087 weight=10;
	}
	
	#主服务
    server {
        listen       8088;
        server_name  localhost;	
		
        location / {
            proxy_pass http://rs;
			proxy_redirect default;
        }
		
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
	
	#文件服务
	server {
        listen       8085;
        server_name  localhost;
		
        location / {
            proxy_pass http://fm;
			proxy_redirect default;
        }
		
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

In this way, we can directly start nginx. It will allocate services according to the weights configured later. If the current service goes down, he will re-select the next service, which can effectively ensure the security of our online business. If you have any problems in the configuration, you can add my private WeChat: 18515422331

Some minor problems can be solved by checking the log of nginx.

Guess you like

Origin blog.csdn.net/qq_38821574/article/details/111186908