Java 弹簧靴&x2B;Apache反向代理:主机和端口的这种组合需要TLS

Java 弹簧靴&x2B;Apache反向代理:主机和端口的这种组合需要TLS,java,spring,apache,spring-boot,ssl,Java,Spring,Apache,Spring Boot,Ssl,我所拥有的: 我有一个Spring Boot应用程序作为docker映像保存在私有注册表中 让我们来加密SSL证书 我运行了以下命令: wgethttps://dl.eff.org/certbot-auto(获取certbot) chmod a+x certbot auto(使其可执行) /certbot auto(运行它) openssl pkcs12-export-in-fullchain.pem-inkey privkey.pem-out keystore.p12-name tomc

我所拥有的:

  • 我有一个Spring Boot应用程序作为docker映像保存在私有注册表中
  • 让我们来加密SSL证书
我运行了以下命令:

  • wgethttps://dl.eff.org/certbot-auto
    (获取certbot)
  • chmod a+x certbot auto
    (使其可执行)
  • /certbot auto
    (运行它)
  • openssl pkcs12-export-in-fullchain.pem-inkey privkey.pem-out keystore.p12-name tomcat-CAfile chain.pem-caname root
    (转换为与Spring引导兼容的密钥)
在我的Spring Boot应用程序中,我将以下条目添加到属性:

security.require-ssl=true
server.ssl.key-store={key_store_location}
server.ssl.key-store-password={key_store_password}
server.ssl.keyStoreType=PKCS12
server.ssl.keyAlias=tomcat
此时,我可以通过:访问我的应用程序,并且证书有效

然后我会这样做: 我的
/etc/apache2/sites enabled/000 default.conf
文件如下所示:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}


ServerAdmin webmaster@localhost
ServerName {domain}

SSLEngine on
SSLProxyEngine On
SSLProtocol All -SSLv2 -SSLv3 # Disable SSL versions with POODLE vulnerability

SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem

ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://localhost:8080/
ProxyPassReverse / https://localhost:8080/

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
在我启动apache2并打开之后

但是,如果我进入,一切都会正常

所以我的问题是:我需要做什么才能摆脱港口,开始工作

多谢各位

编辑:在我按照建议添加了443之后,问题仍然是相同的错误

完整配置文件:

<VirtualHost *:80>
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

        ServerAdmin webmaster@localhost
        ServerName example.com

        SSLEngine on
        SSLProxyEngine On
        SSLProtocol All -SSLv2 -SSLv3

        SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
        SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
        SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem

        ProxyRequests Off
        ProxyPreserveHost On
        ProxyPass / https://localhost:8080/
        ProxyPassReverse / https://localhost:8080/


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

<VirtualHost *:443>
        RewriteEngine On
        RewriteCond %{HTTPS} off
        RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

        ServerAdmin webmaster@localhost
        ServerName example.com

        SSLEngine on
        SSLProxyEngine On
        SSLProtocol All -SSLv2 -SSLv3

        SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
        SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
        SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem

        ProxyRequests Off
        ProxyPreserveHost On
        ProxyPass / https://localhost:8080/
        ProxyPassReverse / https://localhost:8080/

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

重新启动发动机
重写条件%{HTTPS}关闭
重写规则(*)https://%{HTTP\u HOST}%{REQUEST\u URI}
服务器管理员webmaster@localhost
ServerName example.com
斯伦金安
SSLProxyEngine打开
SSLProtocol All-SSLv2-SSLv3
SSLCertificateKeyFile/etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile/etc/letsencrypt/live/example.com/chain.pem
SSLCertificateFile/etc/letsencrypt/live/example.com/fullchain.pem
代理请求关闭
代理主机
ProxyPass/https://localhost:8080/
ProxyPassReverse/https://localhost:8080/
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
#vim:syntax=apachets=4sw=4sts=4srnoet
重新启动发动机
重写条件%{HTTPS}关闭
重写规则(*)https://%{HTTP\u HOST}%{REQUEST\u URI}
服务器管理员webmaster@localhost
ServerName example.com
斯伦金安
SSLProxyEngine打开
SSLProtocol All-SSLv2-SSLv3
SSLCertificateKeyFile/etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile/etc/letsencrypt/live/example.com/chain.pem
SSLCertificateFile/etc/letsencrypt/live/example.com/fullchain.pem
代理请求关闭
代理主机
ProxyPass/https://localhost:8080/
ProxyPassReverse/https://localhost:8080/
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合

默认Https端口为443。请您为443创建SSL VirtualHost,并在VirtualHost和test中添加所有条目

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Listen 443 https
<VirtualHost Apache-IP:443>
ServerAdmin webmaster@localhost
ServerName {domain}

SSLEngine on
SSLProxyEngine On
SSLProtocol All -SSLv2 -SSLv3 # Disable SSL versions with POODLE vulnerability

SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem

ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://localhost:8080/
ProxyPassReverse / https://localhost:8080/

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
重新编写引擎打开
重写条件%{HTTPS}关闭
重写规则(*)https://%{HTTP\u HOST}%{REQUEST\u URI}
听443https
服务器管理员webmaster@localhost
服务器名{domain}
斯伦金安
SSLProxyEngine打开
SSLProtocol All-SSLv2-SSLv3#禁用带有POODLE漏洞的SSL版本
SSLCertificateKeyFile/etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile/etc/letsencrypt/live/example.com/chain.pem
SSLCertificateFile/etc/letsencrypt/live/example.com/fullchain.pem
代理请求关闭
代理主机
ProxyPass/https://localhost:8080/
ProxyPassReverse/https://localhost:8080/
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合

谢谢!不幸的是,结果仍然是一样的。我做了更改并重新启动了apache。共享最新配置和错误日志以供查看。我用请求的信息更新了我的原始帖子。谢谢请从
中删除SSL配置。重新启动Apache httpd并进行测试。我从配置文件的
部分对以SSL开头的所有内容(总共6行)进行了注释,但仍然出现相同的错误。不过http会正确重定向到https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
Listen 443 https
<VirtualHost Apache-IP:443>
ServerAdmin webmaster@localhost
ServerName {domain}

SSLEngine on
SSLProxyEngine On
SSLProtocol All -SSLv2 -SSLv3 # Disable SSL versions with POODLE vulnerability

SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem

ProxyRequests Off
ProxyPreserveHost On
ProxyPass / https://localhost:8080/
ProxyPassReverse / https://localhost:8080/

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>