首页 > 解决方案 > 使用 JDK11 从 2.2.2 升级后的 Spring boot 2.3.3 停止在 Apache HTTP/1.1 上使用 AJP

问题描述

我已经在 jdk11 上从 Spring boot 2.2.2 升级到 2.3.3,但现在应用程序正在运行,但不在 Apache HTTP/1.1 上。我正在使用jdk11。我只是想用 ajp 在 https 上启用它。下面是apache配置:

<VirtualHost ravi.abc.com:443>

DocumentRoot "D:/tools/Apache2.4.x/htdocs"

ErrorDocument 500 /500.html
ErrorDocument 503 /503.html
ErrorDocument 404 /404.html

ServerName ravi.abc.com
ServerAdmin admin@local.com
Include conf/extra/abc/security.conf

RewriteEngine on
RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD|PUT|DELETE|OPTIONS|PROPFIND|LOCK|UNLOCK)$
RewriteRule .* - [F]

RewriteCond %{QUERY_STRING} ^.*(\.jsp|java\.|redirect:|\${|context\.|xwork\.|HttpServletRequest|getBytes|action:|redirectAction:|redirect\%3A|\.java|action\%3A|redirectAction\%3A|\.String|HttpServletResponse).* [NC]
RewriteRule ^(.*)$ - [F,L]

RewriteCond %{REQUEST_URI} ^.*(\.jsp|java\.|redirect:|\${|context\.|xwork\.|HttpServletRequest|getBytes|action:|redirectAction:|redirect\%3A|\.java|action\%3A|redirectAction\%3A|\.String|HttpServletResponse).* [NC]
RewriteRule ^(.*)$ - [F,L]

RewriteEngine on
RewriteCond %{HTTP_HOST} ^ravi\.abc\.com
RewriteRule ^/$ https://ravi.abc.com/ [R=permanent,L]

DirectoryIndex index.html
<Directory "D:/tools/Apache2.4.x/htdocs">
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

SSLCertificateFile "D:/tools/Apache2.4.x/certs/star_local_com.crt"
SSLCertificateKeyFile "D:/tools/Apache2.4.x/certs/star_local_com.key"

SSLEngine on
SSLCompression off
SSLHonorCipherOrder on
SSLProtocol -ALL +SSLv3 +TLSv1
SSLProxyProtocol all -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM

<location /framework_5_5>
    AddOutputFilterByType DEFLATE text/html text/javascript text/css text/xml
    ProxyPass ajp://ravi.abc.com:10090/framework_5_5 timeout=120 Keepalive=On
    ProxyPassReverse ajp://ravi.abc.com:10090/framework_5_5
</location>


SetEnvIf User-Agent ".*MSIE [1-5].*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
SetEnvIf User-Agent ".*MSIE [6-9].*" ssl-unclean-shutdown

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog D:/tools/Apache2.4.x/logs/access_log combined
          
</VirtualHost>                                

并在 apache error.log 下面显示错误

[Tue Aug 25 12:06:53.837254 2020] [proxy:error] [pid 12740:tid 16228] AH00940: AJP: disabled connection for (ravi.abc.com)

春季启动端:application.properties:

appname=@project.name@
current.branch=@current.branch@
build.time=@build.time@
build.info=@build.info@
lastCurrentBranchRevision=@lastCurrentBranchRevision@

spring.flyway.enabled=false
# Actuator info endpoint
info.app.name=${instance.name}
info.app.cbn=${current.branch}
info.app.buildtime=${build.time}

# tomcat configuration
#server.use-forward-headers=true
server.forward-headers-strategy=native
server.servlet.context-path=/collaborate
server.error.whitelabel.enabled=false
context.resources.cache.enabled=true
context.resources.cache.maxsize=100000
server.tomcat.mbeanregistry.enabled=true

# spring jmx enabled
spring.jmx.enabled=true

# spring boot struts plugin
spring.servlet.multipart.enabled=false

logging.file.name=${LOG_PATH}/catalina.log
logging.level.com.opensymphony=ERROR
logging.level.org.apache=WARN
logging.level.freemarker=ERROR
logging.level.com.os.upgrade=DEBUG
logging.level.org.jgroups=WARN

spring.sleuth.baggage-keys=rule-history
spring.sleuth.log.slf4j.whitelisted-mdc-keys=rule-history
spring.sleuth.propagation.tag.whitelisted-keys=rule-history
spring.sleuth.propagation.tag.enabled=true

server.http2.enabled=false
security.require-ssl=true
server.ssl.key-store-type=JKS
server.ssl.key-store=classpath:star_local_com.jks
server.ssl.key-store-password=Admin@123

tomcat.ajp.port=10090
tomcat.ajp.enabled=true
tomcat.ajp.remoteauthentication=false

TomcatConfiguration:AJP连接器相关代码

Connector ajpConnector = new Connector("org.apache.coyote.ajp.AjpNioProtocol");
            ajpConnector.setPort(tomcatProperties.getAjp().getPort());
            ajpConnector.setRedirectPort(serverProperties.getPort());
            ((AbstractAjpProtocol<Long>) ajpConnector.getProtocolHandler()).setSecretRequired(false);
            factory.addAdditionalTomcatConnectors(ajpConnector);

以下是控制台日志:

INFO  [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:@build.time@][cbn:@current.branch@][main][2020-08-25 15:46:33,791]- org.directwebremoting.util.CommonsLoggingOutput.info:Line 51 - - Servlet Engine: Apache Tomcat/9.0.37
INFO  [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:@build.time@][cbn:@current.branch@][main][2020-08-25 15:46:33,792]- org.directwebremoting.util.CommonsLoggingOutput.info:Line 51 - - Java Version:   11.0.8
INFO  [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:@build.time@][cbn:@current.branch@][main][2020-08-25 15:46:33,793]- org.directwebremoting.util.CommonsLoggingOutput.info:Line 51 - - Java Vendor:    AdoptOpenJDK
INFO  [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:@build.time@][cbn:@current.branch@][main][2020-08-25 15:46:33,910]- org.directwebremoting.util.CommonsLoggingOutput.info:Line 51 - Probably not an issue: org.jdom.Document is not available so the jdom converter will not load. This is only a problem if you wanted to use it.
INFO  [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:@build.time@][cbn:@current.branch@][main][2020-08-25 15:46:33,913]- org.directwebremoting.util.CommonsLoggingOutput.info:Line 51 - Probably not an issue: org.jdom.Element is not available so the jdom converter will not load. This is only a problem if you wanted to use it.
INFO  [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:@build.time@][cbn:@current.branch@][main][2020-08-25 15:46:33,951]- org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start:Line 220 - Tomcat started on port(s): 8090 (http) 10090 (http) with context path '/framework_5_5'
INFO  [framework_5_5][traceId:][spanId:][parentSpanId:][spanExportable:][bt:@build.time@][cbn:@current.branch@][main][2020-08-25 15:46:34,335]- org.springframework.boot.StartupInfoLogger.logStarted:Line 61 - Started Main in 33.65 seconds (JVM running for 35.388)

依赖项:

<spring-boot.dependencies.version>2.3.3.RELEASE</spring-boot.dependencies.version>
        <spring-cloud.dependencies.version>Hoxton.SR1</spring-cloud.dependencies.version>

标签: javaspring-bootapachetomcatajp

解决方案


推荐阅读