在此调用中使用两个 cmets 解决了问题。
有一个端口冲突,所以我将 server.xml 和 apache2/../000default.conf 都更改为使用 8443(我发现 443 气质)。
与此同时,我现在在所有 URL 调用中都将“8443”作为端口,而不是没有端口。
-
我将此添加到 .conf 文件中:
SSLProxyEngine 开启
ProxyPass /MyProject/context https://www.mydomain.co.uk/MyProject/context
ProxyPassReverse /MyProject/context https://www.mydomain.co.uk/MyProject/context
还必须
a2enmod proxy_http
和
将 VirtualHost 标记设置为 ip 而不是 '*',即 ipaddress.8443
为了更好地衡量,请使用
检查它是否有效
apache2ctl 配置测试
我并没有对我的应用程序中的 web.xml 做更多的事情,我从我的应用程序中删除了 context.xml。
这确实是一个调整旋钮和转盘直到它起作用的案例,我花了大约 2 周的时间。为什么不容易。
这是我的文件供参考
apache2/..conf
<VirtualHost ipaddress:8443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
LogLevel debug
#SetEnv HTTPS on
SSLEngine on
SSLCertificateFile /etc/ssl/certs/mydomain_co_uk.crt
SSLCertificateKeyFile /etc/ssl/private/www.mydomain.co.uk.key
# SSLCertificateKeyFile /etc/ssl/certs/mydomain_co_uk.pem
SSLCACertificateFile /etc/ssl/certs/mydomain_co_uk.ca-bundle
ServerName www.mydomain.co.uk
SSLProxyEngine on
ProxyPass /MyProject/context https://www.mydomain.co.uk/MyProject/context
ProxyPassReverse /MyProject/context https://www.mydomain.co.uk/MyProject/context
Alias /ProjectName"/var/lib/tomcat8/webapps/ProjectName"
<Directory "/var/lib/tomcat8/webapps/ProjectName">
Options Indexes FollowSymLinks
AllowOverride all
Allow from all
</Directory>
<Location />
Require all granted
</Location>
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
服务器.xml
<Connector
protocol="org.apache.coyote.http11.Http11AprProtocol"
port="8443" maxThreads="200" clientAuth="false"
scheme="https" secure="true" SSLEnabled="true"
SSLCertificateFile="/etc/ssl/certs/mydomain_co_uk.crt"
SSLCertificateKeyFile="/etc/ssl/private/www.mydomain.co.uk.key"
SSLPassword="planetx"
SSLVerifyClient="optional" SSLProtocol="TLSv1+TLSv1.1+TLSv1.2"/>
<Engine name="Catalina" defaultHost="localhost">
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!--
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
-->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
来自我的应用程序 web-inf 的 web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Projectname</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>
com.sun.jersey.server.impl.container.servlet.ServletAdaptor</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<security-constraint>
<web-resource-collection>
<web-resource-name>Projectname</web-resource-name>
<url-pattern>/context</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
</web-app>