在我的应用程序中,我正在做一些标准的场景,其中Java Web应用程序部署在带有Apache代理的JBoss上。 Web应用程序可以从/ esp的上下文访问,所以直接的url将是(但我已经closures了HTTP的Jboss,只有AJP):
http://1.2.3.4:8080/esp
现在,我已经创build了子域,并尝试通过Apache根上下文的代理移动。 所以我想要Apache代理:
https://mysubdomain.domain.com -> ajp -> Jboss /esp context app
我相信我错过了我的configuration明显的东西,只有根应用程序的上下文是可访问的,其余的url已经弄糟上下文以404结束。例如,请求代理是这样的:
https://mysubdomain.domain.com/css/somecss.css -> ajp -> /esp/esp/css/somecss.css
Apacheconfiguration看起来像这样:
<VirtualHost 1.2.3.4:80> ServerName mysubdomain.domain.com RewriteEngine on RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L] </VirtualHost> <IfModule mod_ssl.c> <VirtualHost 1.2.3.4:443> ServerName mysubdomain.domain.com ProxyPass / ajp://localhost:8009/esp/ ProxyPassReverse / ajp://localhost:8009/esp/ <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/mantis> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/esp.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> SSLEngine on SSLCertificateFile /var/keys/server.crt SSLCertificateKeyFile /var/keys/server.key <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory /usr/lib/cgi-bin> SSLOptions +StdEnvVars </Directory> BrowserMatch "MSIE [2-6]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown </VirtualHost> </IfModule>
而且,当我预先添加额外的代理时,一切正常。
ProxyPass /esp/ ajp://localhost:8009/esp/ ProxyPassReverse /esp/ ajp://localhost:8009/esp/
除了这个应用程序可以从apache上访问: /和/esp而我只需要root。 我该如何解决?
我已经有了类似于你在这里的麻烦,终于find了我的相关configuration(适应你所发布的configuration):
ProxyRequests Off ProxyPass / ajp://localhost:8009/esp/ ProxyPassReverse / http://mysubdomain.domain.com/esp/ ProxyPassReverse / https://mysubdomain.domain.com/esp/ ProxyPassReverseCookiePath "/esp" "/"
最初我在ProxyPassRevers中遇到了麻烦,但是也有了Cookiepath,甚至可能需要一个ProxyPassReverseCookieDomain指令(在我的情况下我不需要它)。