配置tomcat 8以获取https的代理支持

时间:2014-03-27 07:27:32

标签: apache tomcat https proxy

我在Ubuntu 12.10上的Tomacat8中部署了webapp,我可以访问它@

https://serverhostname:8443/myapp/。我通过编辑conf / server.xml

为https配置了它

如下。

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
           keystoreFile="/root/.keystore" keystorePass="xxxx" 
           maxThreads="150" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS" />

我希望它在端口80的https://serverhostname访问它。如何为https执行此操作。

到目前为止所做的更改

已安装apache2

Ran命令

a2enmod proxy 
a2enmod proxy_http

在/etc/init.d/apache2.conf中添加了行。

ProxyPass        /myapp https://serverhostname:8443/myapp
ProxyPassReverse /myapp https://serverhostname:8443/myapp

重启apache2。

将conf / server.xml中的连接器更改为

 <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               keystoreFile="/root/.keystore" keystorePass="xxxx" 
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" 
                proxyName="https://serverhostname" proxyPort="80"/>

但是当我访问https://serverhostname时,我得到'网页不可用'。

1 个答案:

答案 0 :(得分:0)

现在正在使用Ubuntu 12.10

完成了更改

的/ etc / apache2的/位点可用/默认-SSL

<VirtualHost _default_:443>

ServerAdmin webmaster@localhost
ServerName hostname.domain
...
...
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
SSLProxyEngine on
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>

ProxyPass /myapp https://hostname.domain:8443/myapp
ProxyPassReverse /mpapp https://hostname.domain:8443/myapp

Redirect permanent / https://hostname.domain:8443/myapp
...

</VirtualHost>

所做的更改始终使用https。

的/ etc / apache2的/位点可用/默认

<VirtualHost>
..
...
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]

</VirtualHost>

对/tomcat/conf/server.xml进行的更改

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               keystoreFile="/root/.keystore" keystorePass="xxxx" 
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" 
                proxyName="https://hostname.domain" proxyPort="443"/>