Remove context name from URL - mod_proxy_ajp with Spring Security - spring

I have a app named "FitnessTracker" running on tomcat, post 8080. I am using Spring Security, and everything works fine when I test it directly on tomcat using http://localhost:8080/FitnessTracker
I then configured mod_proxy_ajp on Apache http 2.2, to access using a domain name, below is my VirtualHost configuration:
<VirtualHost *:80>
ServerName www.testing.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
RewriteEngine on
RewriteRule ^/FitnessTracker/(.*)$ /$1 [P]
ProxyPass / ajp://localhost:8009/FitnessTracker/
ProxyPassReverse / ajp://localhost:8009/FitnessTracker/
</VirtualHost>
Now, when I access www.testing.com/ - it gets redirected to www.testing.com/FitnessTracker/login.html
Is there a way to not have /FitnessTracker/ in the URL? I would like to hide the tomcat Context name from the URL.
Ideally, I want the URL to look like www.testing.com/login.html
I know that this is due to the RewriteRule, but without the rewrite rule spring security with mod_proxy doesn't work - since Spring security redirects to login page along with context name.
Please let me know if you have suggestions.

I think you forgot to rewrite the cookie domain and cookie path. Check ProxyPassReverseCookieDomain directive. From the backend perspective the request path still has to look like /FitnessTracker/

Related

how to configure dynamic urls in httpd.conf file for reverse proxy

I am using apache httpd server for reverse proxy to make cross domain ajax calls.
ProxyPass /v1/virtuals http://mypage.com/:4277/v1/virtuals/abc
ProxyPassReverse /v1/virtuals http://mypage.com:4277/v1/virtuals/xyz
in the above url the abc,xyz will be changed based on the selection.those will be dynamic.so how could i configure the urls with that dynamic content in httpd.conf file
Tried with wild card pattern. but it is not working.
http://mypage.com/:4277/v1/virtuals/
in httpd.conf is sufficient to allow all the urls

How to setup proxy in Apache for REST

I'm trying to setup a simple proxy in Apache for RESTful services that I have on a different server. For example, if I go to https://myclient.com/services/hello it will show me the JSON for the URL https://myserver.com/services/hello.
I'm doing this to get cross-domain ajax working. I've found a lot of information about how to set this up, but none of the suggestions I have found work. I thought this should be fairly straightforward, so it's probably an easy answer for someone.
My current settings are forwarding me to the RESTful URL instead of just showing the content. I'm using a basic Apache setup without virtual hosts and configuring everything in my httpd.conf. I am using SSL and also am using a proxy to Tomcat on the same Apache server:
SSLProxyEngine On
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]
ProxyPass /services/ https://myserver.com/services/
ProxyPassReverse /services/ https://myserver.com/services/
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
I've tried a combination of a lot of other settings as well, including an addition RewriteRule, but this simple configuration is the closest I've gotten.
The problems were due to a SSO server that I had setup - requests were being redirected through this server, and this caused a redirect from the SSO server to the API server. The apache settings were correct.

Tomcat application creates new session on page reload when visited through apache

We have a tomcat application which works fine in IE7/8 and Firefox. The only browser we are having issues with (that we care about at this point) is google Chrome. Users can navigate to the application fine and log in and do whatever they need to do in Firefox and IE. However, when trying to log in with Chrome, the session is apparently lost immediately after log in and when the authenticated user tries to navigate to another page they are bumped back to the log in page. This happens consistently.
I have seen other entries here and elsewhere that suggest that the context path might be to blame. I have tried setting a ProxyReverseCookiePath but that does not fix the problem.
Our virtual host configuration is as follows:
<VirtualHost xxx.xxx.xxx.xxx:80>
ServerAdmin admin#email.com
ServerName subdomain.example.com
DocumentRoot /var/www
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /context/ ajp://127.0.0.1:8009/context/
ProxyPass / ajp://127.0.0.1:8009/context/
#ProxyPassReverse /context/ http://127.0.0.1:8009/context/
#ProxyPassReverse / http://127.0.0.1:8009/context/
#ProxyPassReverseCookiePath /context/ /
</VirtualHost>
There is another application deployed on the same instance of tomcat at the ROOT context. I have looked at the JSESSIONID that is set in the cookie, which is sent back to Chrome and it changes on every request, while it does not for IE and Firefox.
I am at a loss here. Any ideas are welcome!
We are using tomcat 6.0.23 as well as apache 2.2.14
For reference: The problem was solved by deploying the application at root context path and removing the context paths from the proxy statements.
ProxyPass /context/ ajp://127.0.0.1:8009/
ProxyPass / ajp://127.0.0.1:8009/
Nothing else was needed.

2 joomla sites in the same webserver

people i have to create a second site in the same webserver that i already have my first site. i,m not sure on how i can do this, i would not like to have to change all the url that i have already created. i was thinking on installing a second joomla inside the folder where is the first one. the url will be www.myweb1.com/joomla2, that is something that i would not like is there a way by my dns that i can change that www.myweb1.com/joomla2, to www.joomla2.com
I just want to create a new joomla site in the same webserver that i already have one joomla site. I,m using apache2 with opensuse. the first site already have a vhost to manage https rewrite conditions.
Any recomendation.
You can use the proxy functionality of Apache HTTPD.
Such configuration might look like:
<VirtualHost *>
ServerName www.joomla2.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://www.myweb1.com/joomla2
ProxyPassReverse / http://www.myweb1.com/joomla2
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>

Plone with Apache Proxy

I have a plone zinstance set up through Apache Proxy on OS X Server 10.5. The server is set up with a single vhost on port 80, with Proxy & Proxypass directives to the Plone zinstance:
ProxyPass / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
ProxyPassReverse / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
However, I have some static HTML and PHP content that I want to display in an iframe via the plone site. I'm thinking I'll need to set up another vhost on a different port, then just specify the port # inline?
Set up a static URL that will not be proxied but served from Apache directly, like this:
ProxyPass /static !
ProxyPass / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
ProxyPassReverse / http://localhost:8080/VirtualHostBase/http/server:80/Plone/VirtualHostRoot/
Then configure /static to contain your static content.
I'd recommend rolling your configuration into a virtual host block. You can deliver static content directly form apache by rewriting a specific path. Here's an example
<VirtualHost *:80>
ServerName yoursite.com
Alias /static /var/www/some/path/
<Directory "/var/www/some/path">
Options Includes FollowSymLinks
AllowOverride All
</Directory>
# Zope rewrite.
RewriteEngine On
RewriteRule /static - [L]
RewriteRule ^/(.*) http://127.0.0.1:8080/VirtualHostBase/http/%{SERVER_NAME}:80/Plone/VirtualHostRoot/$1 [L,P]
</VirtualHost>
Sorry, not enough information but I'll offer a couple of comments that might help point you in the right direction.
First, ProxyPassReverse is unnecessary as Plone already takes care of fixing up any self-referential urls. That is the point of the crazy url after all.
Another poster already showed how to configure ProxyPass to selectively bypass the proxy to Plone and serve from Apache directly.
Regarding the "additional vhost on port 8888". It's not clear what you mean by this. What is the extra vhost serving? If it's where your static html and php content is supposed to come from then restricting to localhost only means you're going to have to also configure an internal proxy to reach it. You can do that with Rewrite rules but that seems like an overly-complicated way to go in this usecase. Why is this vhost available to localhost only? For that matter, why are using a separate vhost... you can do this all (Plone, static files, and PHP) in just one vhost with the appropriate ProxyPass lines (or Rewrite lines if you need more flexibility).

Resources