Ekkoruse
2019-11-11 16:13
采纳率: 100%
浏览 2.3k
已采纳

Tomcat 小白 http端口80,当用https强行访问80端口时服务器炸掉了,请问如何解决这个问题?

访问
http://localhost/
https://localhost/
http://localhost:443/
https://localhost:443/
http://localhost:80/
没问题

但访问https://localhost:80/会让服务器炸掉

server.xml

    <Connector port="80" protocol="org.apache.coyote.http11.Http11NioProtocol"
               connectionTimeout="20000"
               redirectPort="443" />
    <Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"
               keystoreFile="D:\key\localhost.keystore"
               keystorePass="zqc123456" />

tomcat输出

11-Nov-2019 16:05:28.710 信息 [http-nio-80-exec-4] org.apache.coyote.http11.Http11Processor.service 解析 HTTP 请求 header 错误
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.
        java.lang.IllegalArgumentException: 在方法名称中发现无效的字符串, HTTP 方法名必须是有效的符号.
                at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:415)
                at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:292)
                at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
                at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
                at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579)
                at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
                at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
                at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
                at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
                at java.base/java.lang.Thread.run(Thread.java:830)

出现情况:
图片说明

想要阻止这样的访问或者不理会或者重定向 不知道该怎么做。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • 毕小宝 2019-11-11 16:33
    已采纳

    并没有炸掉的呀,而是 Tomcat 处理不了后台错误了而已。而 https 协议配置的端口是 443 不是 80 ,不匹配就会出错了呀。

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题