weblogic & OHS: How forward one url to a different server - redirect

I have an environment with Oracle WebLogic and OHS running.
In the mod_wl_ohs.conf I have following (beside config for other applications)
<Location /application1>
SetHandler weblogic-handler
WLLogFile /opt/logs/ application1.log
Debug OFF
WebLogicHost 127.0.0.1
WebLogicPort 23666
</Location>
This works fine the and the server listening to 23666 with the actual application1 application is handling the requests like “http://example.com/application1/*” .
Now I would like to redirect all requests for specific URL pattern to a different domain (not necessary on the same server), but continuing handling all requests others.
Redirect: http://example.com/application1/MagicKeyword/*
continue on: http://example.com/application1/NotTheKeyword* or http://example.com/application1/AlsoNotKeyword/*
What is the right approach for that?
I played around with some mod_rewrite rules, it seems they don’t take affect or break everything (in httpd.conf). I was also reading that we should not use mod_rewrite rules inside of location tag (can't find the reference now).
What else can I do?
Edit: So finally I found my error (somehow wrong syntax which not prevented the server from starting (like usual).
So I could:
in httpd.conf
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule "(.*)/application1/MagicKeyword/(.*)$" "https://www.example.org" [NC,L,R=301]
</IfModule>
or in the Location tag add:
RewriteEngine On
RewriteRule "(.*)/MagicKeyword/(.*)$" "https://www.example.org" [NC,L,R=301]
Why should I prefer one over the other?
Is there anything to concern about?

Two other options you can consider. You can use the order of location tags:
<Location /application1/MagicKeyword>
WebLogicHost otherhost
</Location>
<Location /application1>
WebLogicHost 127.0.0.1
</Location>
You can tell WebLogic to exclude a path (see https://docs.oracle.com/middleware/1212/webtier/PLGWL/plugin_params.htm#PLGWL473):
<Location /application1>
WebLogicHost 127.0.0.1
WLExcludePathOrMimeType /application1/MagicKeyword
</Location>
<Location /application1>
WebLogicHost otherhost
</Location>

Related

Why is my catalyst application running Apache+FastCGI not serving dynamic content?

I am trying to run my first Perl Catalyst application using Apache and fastcgi.
Starting the server is fine, I can see the application's main page. All images/javascripts are loaded correctly (so, I assume the static content is served correctly).
For reasons I don't understand the dynamic content gives me a 404: e.g. when trying to go to www.webapp.org/search, I get "The requested URL /search was not found on this server."
Ok, here is how I set the aliases for the static content and
Alias /static /webapp/root/static/
Alias / /webapp/script/webapp_fastcgi.pl
I set the documentroot with
DocumentRoot /webapp/
Furthermore, I have a
<Location />
Options +ExecCGI
Order allow,deny
Allow from all
AddHandler fcgid-script .pl
</Location>
and a directive
<Files /webapp/script/webapp_fastcgi.pl>
PassEnv PERL5LIB
SetHandler fastcgi-script
</Files>
There is nothing else in the config file.
How can I add a directive to allow serving dynamic content (www.webapp.com/search)?
Thanks a lot in advance!
I see a space in AddHandler section. Please check your config file for typo's.
AddHandler fcgid-script .pl
Also please read this if you not did it already:
http://wiki.catalystframework.org/wiki/deployment/apache_fastcgi
For development work you could use catalyst without apache hassle: http://search.cpan.org/~mramberg/Catalyst-Runtime-5.80012/lib/Catalyst/Engine/FastCGI.pm#Standalone_FastCGI_Server
Assuming apxs installed mod_fastcgi.so into /usr/local/apache/libexec, add the following to an Apache .conf file:
LoadModule fastcgi_module libexec/mod_fastcgi.so
<IfModule mod_fastcgi.c>
FastCgiExternalServer /tmp/myapp.fcgi -host myhost:8081
Alias /myapp/ /tmp/myapp.fcgi/
</IfModule>

Spring security logout over https not working

I have basic configuration for Spring SEcurity. The logout button works perfectly fine over HTTP but problem appears when dealing with HTTPS. My security config looks like this:
<http use-expressions="true" auto-config="false" entry-point-ref="http403EntryPoint"
access-denied-page="/accessDenied">
<intercept-url pattern="/**" access="hasRole('AA_ACCESS')" requires-channel="any"/>
<custom-filter position="PRE_AUTH_FILTER" ref="siteminderFilter"/>
<session-management>
<concurrency-control max-sessions="1" expired-url="/sessionExpired"/>
</session-management>
<logout invalidate-session="true" delete-cookies="JSESSIONID"/>
</http>
The logout button:
Logout
As I said, everything works fine over HTTP, but not HTTPS.
I get error 404 Page not found. Ports the app is running is: 11501 for JBoss AS, while HTTPS is Apache with ajp connector to JBoss, apache is 16000, ajp 8009.
Luke Taylor was right. It's not Spring Secuiry issue. Remember kids, check everything twice after your colleagues. In my case, Apache VirtualHost was wrongly configured:
<VirtualHost *:11600>
ServerName localhost
DocumentRoot "/apache/htdocs/aa"
SSLEngine on
SSLCertificateFile "/apache/conf/server.crt"
SSLCertificateKeyFile "/apache/conf/server.key"
ProxyPass /admin ajp://localhost:8009/admin/ <--- HERE
<Directory "/apache/htdocs/aa">
DirectoryIndex index.html
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog "logs/error_log"
CustomLog "logs/access_log" common
LogLevel debug
</VirtualHost>
Notice additional slash at the end of ProxyPass, that was the problem
Not sure why it works on http so i dont know if this will help but you can try to set the logout-success-url on the logout configuration, in case that the 404 error is due to a missing page where you are redirected after the logout is complete.
http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#nsa-logout

Debug /http-bind/ issue Openfire

Im using openfire for the xmpp to my website. I have done a server move and relocated the site on the same server as openfire as they were both on different servers before.
Since the move im getting error 500 on the /http-bind/ request on my website.
How can i debug this or what to i need to consider that may be causing the error 500 on /http-bind/
Error log
[warn] proxy: No protocol handler was valid for the URL /http-bind/. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
Short answer: You need to load the 'proxy_http' module in Apache.
There are some instructions I wrote in the Prosody documentation on setting up BOSH with Apache, but they should apply equally to any BOSH/XMPP server. In particular I'm not sure whether Openfire is fussy about /http-bind vs. /http-bind/. Therefore if the below instructions do not work, try adding the / to the end of the URL.
Summary
Run: sudo a2enmod rewrite proxy proxy_http
Add the following lines to your Apache config:
<Location /http-bind>
Order allow,deny
Allow from all
</Location>
RewriteEngine On
RewriteRule ^/http-bind$ http://example.com:5280/http-bind [P,L]
I would like to add that with a properly configured server you can just put this in your .htaccess in the root of your web folder:
<IfModule mod_rewrite.c>
RewriteEngine On
# Rule1
RewriteCond %{REQUEST_URI} ^/chat1/http-bind
RewriteRule ^.*$ http://chatsrv1.joynmenow.com:7070/http-bind/ [P,L]
# Rule 2
RewriteCond %{REQUEST_URI} ^/chat2/http-bind
RewriteRule ^.*$ http://chatsrv2.joynmenow.com:7070/http-bind/ [P,L]
</IfModule>
I'm not exactly sure what configs are required to allow this in a .htaccess however my godaddy VPS allowed me to do this in it's default configuration.

Mason and Apache configuration, loading files that don't exist

I have a really strange behavior while using Mason, for example:
I have an index.html file ( that contains mason tags like <% $var %> hello ).
When I'm browsing to http://bla.com/index.html the variable is translated during compilation.
But there's a strange behavior when I'm browsing to http://bla.com/index.
Though there's no file called index (only index.html) it still loads index.html and the entire code is shown as plain/text including the <% ... %> !!!
What have I configured wrong ?
this is my Apache configuration:
<VirtualHost *:80>
ServerAdmin webmaster#abc.com
ServerAlias abc.com www.abc.com
ServerName abc.com
DocumentRoot /var/www/abc.com
DirectoryIndex index.html
<Directory "/var/www/abc.com/">
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SetHandler perl-script
PerlModule HTML::Mason::ApacheHandler
PerlSetVar MasonUseObjectFiles 1
<LocationMatch "(\.html|\.txt|\.pl|\.js)$">
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
</LocationMatch>
<LocationMatch "(\.m(html|txt|pl)|dhandler|autohandler)$">
SetHandler perl-script
PerlHandler Apache::Constants::NOT_FOUND
</LocationMatch>
After a ~year I accidently found the answer, so I wanted to share my findings:
The problem was that Mason(Perl) displaying the code itself of another file on the web instead of providing "404 file not found" and I had no idea how to stop it. e.g: when requesting index it shows the code of index.html
The solution is that in my Apache configuration there was the following:
<Directory "/var/www/my_dir/">
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Apparently "MultiViews" is activated through mod_negotiation.c, which cause the site to search for a pattern of the next-best match in-case the file is not found on the server. ( so from www.site.com/index it found index.html )
But because there's no configuration in the Apache to execute /index in Mason ENV ( no file extension ) , it simply displayed the code ...
Funny :) but the solution was to change "Options FollowSymLinks MultiViews" to "Options FollowSymLinks -MultiViews" and not using the MultiViews.
Found this solution while seen the following response headers:
Content-Location index.html
Vary negotiate
The "MultiViews" doesn't have any meaning to me, as it was a copy-paste from a 5 years ago that I simply carried from one web-server to another :)
Thanks,
Ricky.
Why the webserver automagically
translates index into index.html
still insists on treat it specially (it apparently don't feed it into the PerlHandler as it should) I honestly don't know (perhaps the answer is elsewhere in your configuration).
However, you could as a work around try to add 'index' (or perhaps rather'^index') to the regex that defined what files should be dispached to HTML::Mason::ApacheHandler. I do admit it is a bit ugly though.
Am I correct that once you load the index page and get that verbatim code displayed, once you check out the page info, the encoding is literally plain/text? Perhaps you need to configure some mime settings to ensure that files without suffixes (files not ending with .html etc) are not sent to the remote browser at all, not even as plain/text?

Mapping a subdomain to a Servlet context using Apache 2.x and Tomcat 6.x

I have installed Archiva on my machine under Tomcat 6.x at http://dev.mycompany.com:8080/archiva and can access the application and everything, but I want to access it from the subdomain archiva.mycompany.com.
I have Apache 2.x running on port 80 and using Virtual Hosts and mod_proxy to route from other subdomains to the other various services I am running on this machine.
I now want to create a subdomain archiva.dev.mycompany.com and point that to dev.mycompany.com:8080/archiva.
I can't figure out what I need to put in my ProxyPass and ProxyPassReverse to make this work like I want it to.
I tried the following and all it does is add /archiva to the URL over and over again.
<VirtualHost *:80>
ServerAdmin me#mycompany.com
ServerName archiva.dev.mycompany.com
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://dev.mycompany.com:8080/archiva
ProxyPassReverse / http://dev.mycompany.com:8080/archiva
</VirtualHost>
and I get this error message
HTTP Status 404 - /archivaarchiva/
type Status report
message /archivaarchiva/
description The requested resource (/archivaarchiva/) is not available.
I went and dug through everything I could find on Google once again and tried the following:
ProxyPass / ajp://dev.mycompany.com:8080/archiva/
ProxyPassReverse / http://dev.mycompany.com:8080/archiva/
now I just get a 404 error code from the Winstone Servlet Engine, I know I am getting close.
Can anyone tell me what magic incantation I need to make this behave as I desire?
I had the exact same problem.
What has to be done :
reconfigure archiva to have archiva
running on / instead of /archiva/
configure reverse proxy in the
apache2 configuration.
So now i have "http://repo.[domain]/" for main archiva URL, pointing on "http://[domain]:[port]/"
Here's my current Apache2 configuration :
ProxyRequests Off
ProxyPreserveHost On
<VirtualHost [ip]>
ServerName repo.[domain]
ProxyPass / http://[ip]:8082/
ProxyPassReverse / http://[ip]:8082/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
And about the conf/jetty.xml configuration :
-remove this :
<!--
<Call class="org.mortbay.jetty.webapp.WebAppContext" name="addWebApplications">
<Arg><Ref id="Contexts"/></Arg>
<Arg>./apps</Arg>
<Arg>org/mortbay/jetty/webapp/webdefault.xml</Arg>
<Arg><Ref id="plusConfig"/></Arg>
<Arg type="boolean">True</Arg>
<Arg type="boolean">False</Arg>
</Call>
-->
+add this instead:
<New class="org.mortbay.jetty.webapp.WebAppContext">
<Arg><Ref id="Contexts"/></Arg>
<Arg>./apps/archiva</Arg>
<Arg>/</Arg>
<Set name="configurationClasses"><Ref id="plusConfig"/></Set>
</New>
The reason you are getting:
HTTP Status 404 - /archivaarchiva/
is because you didn't end your ProxyPass last path with a / but you did ended the first path with one.
ProxyPass / http://dev.mycompany.com:8080/archiva
both ProxyPass and ProxyPassReverse should end with /
Rewrite to (taking note of the ending /):
ProxyPass / http://dev.mycompany.com:8080/archiva/
see: http:// httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypass
If the first argument ends with a trailing /, the second argument should also end with a trailing / and vice versa. Otherwise the resulting requests to the backend may miss some needed slashes and do not deliver the expected results.