Apache Web 服务器端口 433 和 Tomcat 端口 8080,重定向不起作用

Apache Web Server port 433 and Tomcat port 8080, redirect not working

我的 Apache Web 服务器 运行 在端口 433 上使用 https 协议。我希望 运行 Tomcat 端口 8080 因为不需要额外的加密, Tomcat 在同一台机器上,所以我不需要端口 8433.但是,当我通过 iptables 将流量从 433 转发到 8080 时,我得到了一个错误:此站点无法提供安全连接

ERR_SSL_PROTOCOL_ERROR

我需要在 tomcat server.xmlapache.conf 中进行哪些配置才能完成这项工作?

    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               URIEncoding="UTF-8"
               redirectPort="8443" />
    
    <!-- A "Connector" using the shared thread pool-->
    
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
<!-- I've tried this before when I thought I need an SSL for Tomcat. I think it's irrelevant now -->

<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
           maxThreads="150" SSLEnabled="true" >
    <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
    <SSLHostConfig>
        <Certificate certificateKeyFile="conf/localhost-rsa-key.pem"
                     certificateFile="conf/localhost-rsa-cert.pem"
                     certificateChainFile="conf/localhost-rsa-chain.pem"
                     type="RSA" />
    </SSLHostConfig>
</Connector>

httpd.conf

<VirtualHost *:80>
     ServerAdmin root@localhost
     DocumentRoot "/var/www/html"
     DirectoryIndex index.html
     ServerName mydomain.zone
     ErrorLog "/var/log/httpd/mydomain.zone.error_log"
     CustomLog "/var/log/httpd/mydomain.zone.access_log" common
RewriteEngine on
RewriteCond %{SERVER_NAME} =mydomain.zone
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Include /etc/httpd/conf/httpd-le-ssl.conf

编辑:我试图删除 iptables 规则,然后我添加了 httpd.conf:

ProxyPass / http://www.mydomain.zone:8080
ProxyPassReverse / http://www.mydomain.zone:8080

但我收到消息:服务不可用由于维护停机或容量问题,服务器暂时无法为您的请求提供服务。请稍后再试。 (Tomcat 是 运行ning 我检查过并重新启动了 Apache)。

我注意到我的网络应用程序目前可以使用普通的 HTTP 协议,但不能使用 https,我需要输入 :8080

我遇到了 2 个问题,问题不是关于代理规则,我写对了。

我在这里找到了第一个问题的解决方案:http://sysadminsjourney.com/content/2010/02/01/apache-modproxy-error-13permission-denied-error-rhel/

显然,SELinux 不允许 httpd 无法启动出站连接。我需要允许它:/usr/sbin/setsebool -P httpd_can_network_connect 1

第二个问题是我的 Tomcat 使用了过多的 RAM 内存,因为我在 server.xml 中配置了 SSL,但我的 Apache 中已经启用了 SSL。当我评论出来时,Tomcat 减少了他的 RAM 消耗。