将两个 Web 服务器 https 和 http 请求转发到单个 hybris tomcat 服务器
Forwarding two web servers https and http requests to single hybris tomcat server
我们在同一网络中有两台 apache 2.4.6 网络服务器和一台 hybris tomcat 7 服务器,我需要使用 mod_proxy 配置网络服务器以将 http 和 https 请求转发到 hybris 服务器和网络服务器具有不同的域名。我的问题是如何配置 tomcat 以接受来自两个不同域名的请求以及 proxyName 参数是否足够。下面是我的基本 mod_proxy 配置。
LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule ssl_module modules/mod_ssl.so
<VirtualHost *:80>
DocumentRoot /var/www/html
ProxyPreserveHost On
ProxyPass / http://tomcatserver.ip:9001/
ProxyPassReverse / http://tomcatserver.ip:9001/
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/www/html
ProxyPreserveHost On
ServerName webserver.ip
SSLEngine on
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyPass / https://tomcatserver.ip:9002/
ProxyPassReverse / https://tomcatserver.ip:9002
SSLCertificateFile /etc/ssl/certs/webserverdomain.crt
SSLCertificateKeyFile /etc/ssl/certs/webserverdomain.key
</VirtualHost>
server.xml configuration
<Connector port="${tomcat.http.port}"
maxHttpHeaderSize="8192"
maxThreads="${tomcat.maxthreads}"
protocol="org.apache.coyote.http11.Http11Protocol"
executor="hybrisExecutor"
enableLookups="false"
acceptCount="100"
connectionTimeout="20000"
URIEncoding="UTF-8"
disableUploadTimeout="true"
proxyName="webserverdomainname" proxyPort="80" /> />
<Connector port="${tomcat.ssl.port}"
maxHttpHeaderSize="8192"
maxThreads="150"
protocol="org.apache.coyote.http11.Http11Protocol"
executor="hybrisExecutor"
enableLookups="false"
acceptCount="${tomcat.acceptcount}"
connectionTimeout="20000"
disableUploadTimeout="true"
URIEncoding="UTF-8"
SSLEnabled="true"
proxyName="webserverdomainname"
proxyPort="443"
scheme="https"
secure="true"
clientAuth="false"
sslProtocol = "TLS"
keystoreFile="${catalina.home}/lib/keystore"
keystorePass="123456"enter code here
如果我理解正确的话,您有 2 个具有 2 个不同域名的 Apache Web 服务器,您想连接到同一个 Hybris Tomcat。
如果这是正确的,那么您唯一需要配置的就是配置 Hybris 网站 url 映射以捕获所有必需的域名。
关于代理名称,来自 Tomcat 7 文档:
Proxy name : If this Connector is being used in a proxy configuration,
configure this attribute to specify the server name to be returned for
calls to request.getServerName(). See Proxy Support for more
information.
如果您必须配置 Tomcat 以将不同的域名与不同的主机匹配,请查看 the host container。
我们在同一网络中有两台 apache 2.4.6 网络服务器和一台 hybris tomcat 7 服务器,我需要使用 mod_proxy 配置网络服务器以将 http 和 https 请求转发到 hybris 服务器和网络服务器具有不同的域名。我的问题是如何配置 tomcat 以接受来自两个不同域名的请求以及 proxyName 参数是否足够。下面是我的基本 mod_proxy 配置。
LoadModule headers_module modules/mod_headers.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule ssl_module modules/mod_ssl.so
<VirtualHost *:80>
DocumentRoot /var/www/html
ProxyPreserveHost On
ProxyPass / http://tomcatserver.ip:9001/
ProxyPassReverse / http://tomcatserver.ip:9001/
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/www/html
ProxyPreserveHost On
ServerName webserver.ip
SSLEngine on
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyPass / https://tomcatserver.ip:9002/
ProxyPassReverse / https://tomcatserver.ip:9002
SSLCertificateFile /etc/ssl/certs/webserverdomain.crt
SSLCertificateKeyFile /etc/ssl/certs/webserverdomain.key
</VirtualHost>
server.xml configuration
<Connector port="${tomcat.http.port}" maxHttpHeaderSize="8192" maxThreads="${tomcat.maxthreads}" protocol="org.apache.coyote.http11.Http11Protocol" executor="hybrisExecutor" enableLookups="false" acceptCount="100" connectionTimeout="20000" URIEncoding="UTF-8" disableUploadTimeout="true" proxyName="webserverdomainname" proxyPort="80" /> /> <Connector port="${tomcat.ssl.port}" maxHttpHeaderSize="8192" maxThreads="150" protocol="org.apache.coyote.http11.Http11Protocol" executor="hybrisExecutor" enableLookups="false" acceptCount="${tomcat.acceptcount}" connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8" SSLEnabled="true" proxyName="webserverdomainname" proxyPort="443" scheme="https" secure="true" clientAuth="false" sslProtocol = "TLS" keystoreFile="${catalina.home}/lib/keystore" keystorePass="123456"enter code here
如果我理解正确的话,您有 2 个具有 2 个不同域名的 Apache Web 服务器,您想连接到同一个 Hybris Tomcat。
如果这是正确的,那么您唯一需要配置的就是配置 Hybris 网站 url 映射以捕获所有必需的域名。
关于代理名称,来自 Tomcat 7 文档:
Proxy name : If this Connector is being used in a proxy configuration, configure this attribute to specify the server name to be returned for calls to request.getServerName(). See Proxy Support for more information.
如果您必须配置 Tomcat 以将不同的域名与不同的主机匹配,请查看 the host container。