Apache SSL 端口重定向(8443 到 443)

Apache SSL 端口重定向(8443 到 443)

我有一个 Tomcat 服务器 (JIRA) 在 Apache 反向代理服务器后面运行(花了一段时间,但我做到了)。我正在升级我的旧服务器并添加 Apache 以提供一些额外的功能和安全性。旧服务器的访问时间为

https://example.com:8443

我希望能够让 Apache 将访问端口 8443 的旧地址的任何人(即来自旧书签等)转发到,https://example.com但我很难让它工作。我可以执行以下操作

  • http://example.com->https://example.com
  • http://example.com:8443->https://example.com

https://example.com:8443在 Chrome 中生成 SSL 连接错误。我有点困惑。在 httpd.conf 中我有

Listen 80
Listen 8443

在 httpd-vhosts.conf 中我有

<VirtualHost *:80>
    ServerName example.com
    Redirect        /   https://example.com/
</VirtualHost>
<VirtualHost *:8443>
    ServerName example.com
    Redirect    /   https://example.com/
</VirtualHost>

在 httpd-ssl.com 我有

Listen 443
<VirtualHost *:443>
    ServerName example.com

    SSLEngine               On
    SSLCertificateFile      "C:\Program Files\Atlassian\JIRA\jre\server.crt"
    SSLCertificateKeyFile   "C:\Program Files\Atlassian\JIRA\jre\server.key"
    SSLProxyEngine      Off

    ProxyRequests       Off
    ProxyPreserveHost   On
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass           /   http://example.com:8080/
    ProxyPassReverse    /   http://example.com:8080/

</VirtualHost>

答案1

您仍然需要在端口 8443 上使用 SSL 才能读取请求并做出响应。

答案2

我在 apache 中将它与 Jira 一起使用。注意:我使用在 jira/conf/server.xml 中配置的 /jira(见下文)。另请注意 proxyName="example.com"

<VirtualHost *:80>
        ServerName example.com
        Redirect permanent / https://example.com/jira/
</VirtualHost>

<VirtualHost *:443>

        ServerName example.com
        Redirect permanent / https://example.com/jira/
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>

        ProxyRequests Off
        ProxyPass /jira http://localhost:8080/jira
        ProxyPassReverse /jira http://localhost:8080/jira
        <Location />
                Order allow,deny
                Allow from all
        </Location>

        SSLEngine on
        SSLCertificateFile ....crt
        SSLCertificateKeyFile ....key
        SSLCertificateChainFile ....crt
</VirtualHost>

服务器.xml

<?xml version="1.0" encoding="utf-8"?>

<Server port="8005" shutdown="SHUTDOWN">

    <!--APR library loader. Documentation at /docs/apr.html -->
    <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on"/>
    <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
    <Listener className="org.apache.catalina.core.JasperListener"/>
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>

    -->
    <Service name="Catalina">


 <Connector acceptCount="100"
connectionTimeout="20000"
disableUploadTimeout="true"
enableLookups="false"
maxHttpHeaderSize="8192"
maxThreads="150"
minSpareThreads="25"
port="8081"
protocol="HTTP/1.1"
redirectPort="8443"
useBodyEncodingForURI="true"/>

        <Connector acceptCount="100"
connectionTimeout="20000"
disableUploadTimeout="true"
enableLookups="false"
maxHttpHeaderSize="8192"
maxThreads="150"
minSpareThreads="25"
port="8080"
protocol="HTTP/1.1"
redirectPort="8443"
useBodyEncodingForURI="true"
scheme="https"
proxyName="example.com"
proxyPort="443"/>

        <Engine name="Catalina" defaultHost="localhost">
            <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">

                <Context path="/jira" docBase="${catalina.home}/atlassian-jira" reloadable="false" useHttpOnly="true">

                    <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction"
                              factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/>
                    <Manager pathname=""/>
                </Context>

            </Host>
            <Valve className="org.apache.catalina.valves.AccessLogValve" resolveHosts="false"
                   pattern="%a %{jira.request.id}r %{jira.request.username}r %t &quot;%m %U%q %H&quot; %s %b %D &quot;%{Referer}i&quot; &quot;%{User-Agent}i&quot; &quot;%{jira.request.assession.id}r&quot;"/>

        </Engine>
    </Service>
</Server>

相关内容