# nginx反向代理报 IllegalArgumentException
代理Tomcat9
- 配置完nginx,访问反向代理的路径时报异常,异常信息如下:
java.lang.IllegalArgumentException: The character [_] is never valid in a domain name.
at org.apache.tomcat.util.http.parser.HttpParser$DomainParseState.next(HttpParser.java:963)
at org.apache.tomcat.util.http.parser.HttpParser.readHostDomainName(HttpParser.java:859)
at org.apache.tomcat.util.http.parser.Host.parse(Host.java:71)
at org.apache.tomcat.util.http.parser.Host.parse(Host.java:45)
at org.apache.coyote.AbstractProcessor.parseHost(AbstractProcessor.java:288)
at org.apache.coyote.http11.Http11Processor.prepareRequest(Http11Processor.java:810)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:384)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:853)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
- 经过仔细排查和上网查询,是配置时负载均衡配置出了问题
原因是在nginx配置文件中配置upstream时用了“_”字符!!
//报错时候是这样的
upstream tomcat_server{
server 127.0.0.1:8080;
}
//修改后
upstream tomcatServer{
server 127.0.0.1:8080;
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
参考:https://www.cnblogs.com/arebirth/p/nginxerror_.html