i have java web app built spring mvc running on tomcat proxied apache httpd running on ec2 instance @ aws , configured load balancer ssl.
the request
first goes load-balancer, load-balancer redirects connection apache (https http because ssl configured load-balancer)
apache redirects localhost (tomcat).
when controller "/first_uri" makes redirect
redirect:https://sub.some_domain/some_uri
i see result @ browser
i couldn't figure out must configure here, configure spring? configure apache httpd or load balancer?
if faced same issue please help.
not: using spring security.
not2: tried without ssl (using http) , same thing happens, think not related https usage.
update: problem may occur try redirect subdomain
solution: proxypreservehost must turned off!
reason: if switched on, response headers returned proxy backend contain “localhost” or real domain without port number (or 80). proxypassreverse pattern not match (because of different port , if domain name used, domain name not match).
config:
<virtualhost localhost:80> proxypreservehost off proxypass / http://localhost:8080/webapp/ proxypassreverse / http://localhost:8080/webapp/ </virtualhost>
but works via http, not via ajp (i don’t know why). if still want use ajp use following workaround - let apache redirect after wrong redirect:
<virtualhost localhost:80> proxypass /webapp ! proxypass / ajp://localhost:8009/webapp/ proxypassreverse / ajp://localhost:8009/webapp/ redirectmatch 301 ^/webapp/(.*)$ /$1 redirectmatch 301 ^/webapp$ / </virtualhost>
the proxypass /webapp !
directive needed exclude path further processing in mod_proxy (because proxy directives evaluated before redirect directives)
then redirectmatch
directives redirect stating /webapp/...
respectively /webapp
url without /webapp
@ beginning.
the drawback must not have sub folder named webapp
in web application
Comments
Post a Comment