Nginx HTTP状态 400 – 错误的请求

释放双眼,带上耳机,听听看~!

nginx upstream代理tomcat 访问提示 HTTP状态 400 - 错误的请求

HTTP状态 400 - 错误的请求

类型 异常报告
消息 The character [_] is never valid in a domain name.
描述 由于被认为是客户端对错误(例如:畸形的请求语法、无效的请求信息帧或者虚拟的请求路由),服务器无法或不会处理当前请求。
例外情况
java.lang.IllegalArgumentException: The character [_] is never valid in a domain name.
    org.apache.tomcat.util.http.parser.HttpParser$DomainParseState.next(HttpParser.java:974)
    org.apache.tomcat.util.http.parser.HttpParser.readHostDomainName(HttpParser.java:870)
    org.apache.tomcat.util.http.parser.Host.parse(Host.java:71)
    org.apache.tomcat.util.http.parser.Host.parse(Host.java:45)
    org.apache.coyote.AbstractProcessor.parseHost(AbstractProcessor.java:298)
    org.apache.coyote.http11.Http11Processor.prepareRequest(Http11Processor.java:797)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:350)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:880)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1601)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.lang.Thread.run(Thread.java:748)
):注意 主要问题的全部 stack 信息可以在 server logs 里查看

Apache Tomcat/9.0.40

解决方法:

由于upstream不支持下划线,需要将下划线(_)修改为-

1648547264996.png

upsteam修改为-

        upstream tomcat-8081 {
          server 172.24.4.129:8081;
          server 172.24.4.130:8081;
    }

proxy_pass

        location / {
            proxy_pass http://tomcat-8080/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
        }

给TA打赏
共{{data.count}}人
人已打赏
报错锦集

No server certificate verification method has been enabled

2022-3-21 13:45:19

报错锦集

Mysql 主从提示 No query specified

2022-3-29 18:08:15

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索