下载启动直接略过,记录一下使用nginx做负载均衡时遇到的两个问题
1、
java.lang.IllegalArgumentException: The character [_] is never valid in a domain name.
把对应的下划线去掉就行
2、启动成功后静态资源文件加载不到,增加一下配置
location ~ .* {
proxy_pass http://upstreamname;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forw $proxy_add_x_forwarded_for;
}
3、提示我未登录,我立马想到了是不是session没有共享的问题,特地去把项目中加上session共享,果然问题解决,解决如下
<!-- Redis依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- Redis session -->
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
#Redis
spring.redis.database=0
spring.redis.host=127.0.0.1
spring.redis.port=6379
spring.redis.password=
spring.redis.timeout=300000ms
spring.redis.jedis.pool.max-active=512
spring.redis.jedis.pool.min-idle=0
spring.redis.jedis.pool.max-idle=8
spring.redis.jedis.pool.max-wait=-1ms
#redis session
spring.session.redis.namespace=evidence
spring.session.store-type=redis
最重要的一步**@EnableRedisHttpSession //开启session共享**