Apache + MOD_JK:重写url+ ProxyPassing通过AJP

我有一个Apache 2.4.23 + OpenSSL 1.0.2j正面服务器。

然后我安装了Tomcat 7的另一台服务器。

这个想法是,Apache在*:443上有一个VHOST,它使用ProxyPass根据指定的URL通过AJP发送请求到Tomcat服务器。

这是我的vhosts.conf文件(它有SSLconfiguration,因为我不想使用httpd-ssl.conf文件,因为我必须改变很多东西),根据这个网站:

https://mozilla.github.io/server-side-tls/ssl-config-generator/

################################################################################################################## # VHOSTS HTTP # redirect all HTTP to HTTPS (optional) <VirtualHost *:80> ServerAlias * RewriteEngine On RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [redirect=301] </VirtualHost> ################################################################################################################## # VHOSTS HTTPS Listen 443 # modern configuration, tweak to your needs SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1 SSLProxyProtocol all -SSLv3 -TLSv1 -TLSv1.1 SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256 SSLProxyCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256 SSLHonorCipherOrder on SSLCompression off SSLSessionTickets off SSLPassPhraseDialog builtin SSLSessionCache "shmcb:c:/ap24/logs/ssl_scache(512000)" SSLSessionCacheTimeout 300 # OCSP Stapling, only in httpd 2.3.3 and later SSLUseStapling on SSLStaplingResponderTimeout 5 SSLStaplingReturnResponderErrors off SSLStaplingCache "shmcb:c:/ap24/logs/ocsp(128000)" <VirtualHost *:443> SSLEngine on SSLCertificateFile "conf/xin.foo.com/xin.crt" SSLCertificateChainFile "conf/xin.foo.com/bundle.crt" SSLCertificateKeyFile "conf/xin.foo.com/xin.key" # Uncomment the following directive when using client certificate authentication #SSLCACertificateFile /path/to/ca_certs_for_client_authentication # HSTS (mod_headers is required) (15768000 seconds = 6 months) Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" ProxyRequests Off ProxyPreserveHost On ProxyPass /bar ajp://XXXX:XXXX/bar/ ProxyPass /bar/ ajp://XXXX:XXXX/bar/bar.html </VirtualHost> 

现在你可以看到,根据URL的方式,我有两个proxypasses。 那是因为我和“admin”/后台区域以及用户区域。 第一个proxypass是每个pipe理员区域,第二个是用户区域。

现在,对于这些网站我需要这些URLS:

pipe理员: https //xin.foo.com/bar/bar

用户: https //xin.foo.com/bar/bar? app =个人

我现在在“本地”上下文中使用Apache服务器,这意味着我没有一个TLD子域已经与Apache服务器上的公共IP。 所以,在我办公室的本地机器上,我编辑了“windows / system32 / drivers / etc”中的“hosts”文件,并添加了以下内容:

xin.foo.com YYYY (which is the IP address of the Apache frontal server). 这样我就可以从我的机器上效仿,从inet中获得的公共访问将是什么。

说到这一切,现在来的东西:

Inet的人,将访问https://xin.foo.com 。 而已。

我想要“ https://xin.foo.com ”直接访问USER区域

像https://xin.foo.com/admin ,访问ADMIN后端区域

那么,在这里我猜想有两件事情需要考虑:

  • AJP proxypasses
  • 用参数或其他东西mod-rewrite的可能性,强制已经configuration的proxypasses工作? 作为在Tomcat服务器上安装的应用程序,需要一些参数(?app = personal)来显示用户区域。 没有参数=pipe理员区域。

也许我必须删除Proxpsesses并做一些mod_proxy_ajp它?

什么是正确的做法,以及如何做? 我将不胜感激最后的秘诀,因为mod_rewrite和Porxypass不是我的专业…而且我确信,即使那两个代理人错误,但这就是他们给我的。

根据评论编辑:

现在,所有的工作都在进行中,但是我需要按照前面的解释来写URL,以便访问合适的区域。 我想要的是根据什么是逻辑来改变服务器的行为,让简单的TLD url进入用户区域,“/ admin”作为后台区域。 我已经添加了从http到https的rewirte,这工作正常。 现在我认为我可以添加一个重写它​​说:

“如果https://xin.foo.com THEN https://xin.foo.com/bar/bar?app=personal ”

“如果https://xin.foo.com/admin THEN https://xin.foo.com/bar/bar ”

有了这个,我想AJP的propasses应该仍然正常工作。 那么A +级别是什么,将不会修改浏览器的URL,所以人们一直在阅读“ https://xin.foo.com ”的真实和“隐藏”的“ https:// xin”。 foo.com/bar/bar?app=personal “。

非常感谢你们,并且非常感谢。