我在 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
运行命令
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
时,我得到“网页不可用”。
最佳答案
现在可以在 Ubuntu 12.10 上运行了
完成的改变
/etc/apache2/sites-available/default-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/sites-available/default
<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"/>
关于apache - 为 https 的代理支持配置 tomcat 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22680869/