Plone with Apache Proxy - 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).

Related

Conditional reverse proxy in apache

if request comes from public ip 50.12.95.78. Proxypass to http://192.168.1.100/quote url.
if request comes from other public ip . Proxypass to http://192.168.1.100/ url
What is the settings for it in apache? Reverse proxy wont work in if condition.
You can set up a conditional reverse proxy in Apache httpd by utilizing mod_proxy and mod_rewrite.
For instance, if you originally had your reverse proxy set up with the following configuration:
ProxyPass / http://192.168.1.100/
ProxyPassReverse / http://192.168.1.100/
It can be made conditional by using the proxy flag on a RewriteRule. An example configuration could look like this:
RewriteEngine On
ProxyPassInterpolateEnv On
RewriteCond "%{REMOTE_ADDR}" =50.12.95.78
RewriteRule (.*) http://192.168.1.100/quote$1 [P,E=proxy_pass_path:/quote]
RewriteRule (.*) http://192.168.1.100$1 [P]
ProxyPassReverse / http://192.168.1.100${proxy_pass_path}/ interpolate
The first RewriteRule is applied and proxied only if the preceding
RewriteCond directive is matched, i.e. if the Remote IP
Address is 50.12.95.78.
The [P]roxy flag also prevents further RewriteRule directives from being applied.
The environmental variable proxy_pass_path is set to tell the ProxyPathReverse directive that the path has been modified.
The second RewriteRule
is automatically applied if the first did not evaluate.
Finally, the
ProxyPathReverse directive is modified to rewrite response headers
based on the proxy_pass_path variable.
Going beyond the scope of your question, bear in mind that this kind of proxy will not implement any real form of security. IP addresses other than 50.12.95.78 will still be able to access http://192.168.1.100/quote simply by requesting http://<Proxy_Host>/quote.

apache rewrite rules are not working after adding proxy pass

i am trying to rewrite the url in apache which internally redirect the requests to apache tomacat
Here is my httpd.conf code
<IfModule mod_rewrite.c>
ProxyRequests Off
ProxyVia Off
ProxyPreserveHost On
ProxyPass / http://localhost:8080/myapp/my.html
ProxyPassReverse / http://localhost:8080/myapp/my.html
RewriteEngine on
RewriteRule ^/(.*)/$ http://localhost:8080/myapp/my.html?product=$1 [QSA]
</IfModule>
so basically what i am trying to do is if i enter localhost/myapp then it should redirect me to localhost:8080/myapp/my.html
Next is if i enter the url localhost/myapp/8 it should redirect internally to localhost:8080/myapp/my.html?product=8.
Now the problem is ProxyPass is working absolutely fine. But the rewrite rule is showing 404 error.
If i remove the ProxyPass code then the same rewrite rule works but it shows the modified url in the browser.
So i want to know where should i place RewriteRule to make it work with ProxyPass and y the rewrite rule is showing the modified urls?
You need to add the [P] flag to the RewriteRule. This causes the RewriteRule to 'proxy' the same way your ProxyPass directive does. At the moment your rule doesn't make any sense. Alternatively you could do something like:
RewriteRule ^/(.*)/$ /myapp/my.html?product=$1 [QSA,PT]
Which should cause the URL to be rewritten and then passed through (this happens because of the PT flag) to any remaining modules that need to process the URI path, in this case the proxy module.
FYI the terminology is wrong, when you say if i enter localhost/myapp then it should redirect me to localhost:8080/myapp/my.html you really mean if i enter localhost/myapp then it should proxy to localhost:8080/myapp/my.html. A redirect is an external response which cases the browser to request a new URL and the text in the browsers address bar will change.
Mind you, with your current configuration, requesting localhost/ will proxy to localhost:8080/myapp/my.html. So if you can specify which is correct it would help.

Remove context name from URL - mod_proxy_ajp with Spring Security

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/

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

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>

Resources