Change Solr base context path - apache

I've installed a Solr (5.3.1 and 5.5.0) in a Ubuntu machine.
With apache I've made a
ProxyPass /MySolr http://{url}:8984/solr
ProxyPassReverse /MySolr http://{url}:8984/solr
So, when I load {url}/MySolr the Dashboard doesn't load because one json.
http://{url}/solr/admin/cores?wt=json&indexInfo=false&_=...
That's normal because the correct URL to load would be:
http://{url}/MySolr/admin/cores?wt=json&indexInfo=false&_=...
When i see the other resouces, solr get the correct URL like:
http://{url}/MySolr/js/scripts/segments.js?_=5.5.0
Any idea?

This process will not work because probably this json is specified with absolute path. In this case Solr doesn't know your mapping. If you want to change the context path you need to change this configuration on Jetty. This way solr will start using the new context.
The first step is create a symbolic link MySolr pointing to solr directory (default located in $SOLR_INSTALL_DIR/server/).
Now change the Jetty configuration file $SOLR_INSTALL_DIR/server/contexts/solr-jetty-context.xml to point to the new context path like this:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath"><Property name="hostContext" default="/MySolr"/></Set>
<Set name="war"><Property name="jetty.base"/>/solr-webapp/webapp</Set>
<Set name="defaultsDescriptor"><Property name="jetty.base"/>/etc/webdefault.xml</Set>
<Set name="extractWAR">false</Set>
</Configure>
Now just restart Solr to be able to access using the new base context path.

Related

How to preserve Apache Tomcat7 configuration files when reinstalling application

I am using Apache Tomcat7 for one of my projects and in order to store some container specific configuration, I am using an XML file under the /etc/tomcat7/Catalina/localhost/ directory (in linux). For example /etc/tomcat7/Catalina/localhost/my-app.xml if the app in question is called my-app.
When I reinstall (update) the application, the afore mentioned file, seems to be deleted during the installation process. Is there any way to preserve this file?
Yes! Have done this mistake quite some time.
There are several conditions (like changing the war file, deleting the webapp or replacing it with new content) under which tomcat will undeploy the context including removing the context file.
You should stop your server before making any changes like changing your war file. If you try to edit or move the deployed war file the corresponding configuration in conf/Catalina/localhost/ will get deleted.
If you do not wish this behavior you can edit the server.xml file located in conf/ directory.
Change
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
and make autoDeploy="false"
For more details you can refer to Apache Tomcat Configuration Reference

Unable to find httpd.conf

I'm running tomcat and I want to change the default webroot so that it points to another location. Is there a way to find out what's running tomcat or where the default webroot is set as I can't find httpd.conf which is where I believe it's usually set?
Cheers,
Alexei Blue.
**UPDATE:**
It's been a long time since I looked at this question that I forgot about it. In the end it turned out that we were using Apache HTTPD to accept requests from port 80. From there we had the webroot and ProxyPass rules set in the /etc/httpd/conf/virtual-hosts/default.conf file (these can also be set in /etc/httpd/conf/httpd.conf). From there we had several tomcat instances running, all hosted on different ports which are setup in apache-tomcat-x/conf/server.xml.
When I wrote this question I was trying to setup a new tomcat instance to run an application in development and was told I would need to change the webroot to access my application, which was incorrect. Instead what I needed was to include a ProxyPass rule so that when my application name was recognised in the URL, HTTPD would send the request to the correct tomcat instance to be processed.
E.g.
www.domain.com/myApplication
In /etc/httpd/conf/virtual-hosts/default.conf
ProxyPass /myApplication/ ajp://127.0.0.1:<ajp_port>/myApplication/
ProxyPassReverse /myApplication/ ajp://127.0.0.1:<ajp_port>/myApplication/
Where the ajp_port is setup in apache-tomcat-x/conf/server.xml. I needed to ensure that non of the ports conflicted with other tomcat instances so remember to check all ports i.e. Shutdown, HTTP, HTTP with SSL, AJP etc.
Tomcat doesn't use httpd.conf, that is an apache file. The location of the individual webapps are kept in their individual web.xml files, but the location of all the configs are in ../tomcat6/conf/server.xml and web.xml
Is it where the files come from you want to move, or where it compiles and executes them from?
As #Woody says, Tomcat does not use httpd.conf files: that's an Apache httpd thing (httpd is a web server, Tomcat is a Java application server).
You didn't mention what OS you are using or what package management software you are using (e.g. yum, apt, etc.) so I'll give you generic information as if you had downloaded and installed Tomcat directly from apache.org (which I usually recommend people do for a number of reasons).
Tomcat keeps its server-wide configuration in the conf/server.xml file in the Tomcat base installation directory (often called $CATALINA_BASE for convenience): here, you configure things like what types of connectors (e.g. HTTP, HTTPS, AJP, etc.) to use and which ports they should listen to, clustering configuration, session persistence, global JNDI and realm resources. There are also conf/web.xml and conf/context.xml files that define defaults for all webapps deployed on that instance of Tomcat, but it's best to leave those files alone unless you have a really good reason to modify them.
When you want to deploy a webapp (under the default configuration), all you need to do is drop a .WAR file into the $CATALINA_BASE/webapps/ directory and the webapp will be deployed into a "context path" (aka URL prefix) that matches the name of the file minus the ".WAR" suffix. So, if you have a WAR file called mygreatwebapp.war, then it will be deployed such that your clients can reach it at http://yourhost/mygreatwebapp/. There is a special name you can give a WAR file so that it has an empty context path: if you name your WAR file ROOT.war (case matters), then your webapp can be reached at http://yourhost/. (If you would rather use exploded-WAR directories instead of WAR files, everything above still applies except the directories simply don't have the .war extension).
Given your original question, it sounds like all you want to do is drop a ROOT.war file into $CATALINA_BASE/webapps (or replace the one that is already there): this will deploy whatever webapp you want into the URL space that you might call the "default webroot".
Update
If you want to change the directory where all the webapps live for a host, you can modify $CATALINA_BASE/conf/server.xml and change the <Host>'s appBase attribute to point to, say, /cfusion/main/www/. That will deploy all the WAR files and directories in /cfusion/main/www/ as separate webapps.
If you just want to serve a single webapp from an arbitrary location, you may create a deployment file under $CATALINA_BASE/conf/[EngineName]/[HostName]/[appname].xml. This is a standard file like META-INF/context.xml and contains a <Context> element except that you will have to specify a docBase which points to your webapp (e.g. /cfusion/main/www/mywebapp).

glassfish using virtual directory

I'm triing to host some files on my glassfish server.
i found this post explaining how to do this with virtual directories:
http://www.marceble.com/2009/07/virtual-directories-in-glassfish/
but this doesn't work for me
when i surf to: localhost:8080/media/test.txt
i get: HTTP Status 404: The requested resource () is not available.
screenshot of my glassfish controlpanel:
http://i77.photobucket.com/albums/j74/bertyhell/glassfish_error.png
Better is this article.
For GlassFish 3.1.x now it is glassfish-web.xml file inside your application config. If you use something like this:
from=/media/* dir=C:/
or the same inside glassfish-web.xml file:
<property name="alternatedocroot_1" value="from=/media/* dir=C:/"/>
Be sure that you created direcotry on your computer: C:/media
"from" must match directory on your computer.
So then it will be available here:
http://{hostName}:{portNumber}/myapp/media/*

Running jsp files from /srv/http using Apache HTTP server and Tomcat

I'd like run jsp files directly from /srv/http without deploying them the Tomcat-way. For example, I want to be able to create symbolic link to my webapp directory (e.g. /home/user/myapp/) in /srv/http and access some app's page through http://localhost/myapp/page.jsp.
Is this possible and how would I set this up?
NOTE: This is not for production. We have to use JSP at university and I want to be able to quickly test my pages.
Open the server.xml of your Tomcat. Assuming if your are using Tomcat 6.x+ then it would be at /tomcatDir/conf/server.xml.
Make an entry with your path
<Context path="/myapp" docBase="yourPathGoesHere" debug="0" reloadable="true" />
Restart Tomcat if already running.
What I did at the moment was creating a symlink in /var/lib/tomcatX/webapps to my project path. This is not the answer I was looking for though, but it is a way to deploy an app without much work.
(X in the above path means your Tomcat version)
If you set <Host name="localhost" appBase="/srv/http"> then all of the directories in it will be deployed as web applications.
If you want /srv/http to be the ROOT application/directory add a file: tomcat/conf/Catalina/localhost/ROOT.xml
with the Context docBase="/srv/http", rather than adding a Context definition to server.xml - this has been strongly discouraged for years.

Is it possible to alias Glassfish requests like in Apache?

I want to redirect requests to /program.fcgi? to the actual location on the filesystem which is /usr/local/.../program.fcgi?. In Apache I can add the following to the configuration file
Alias /program /usr/local/.../program
How do I do the same in Glassfish?
Glassfish lets you include a sun-web.xml in WEB-INF of your web application that allows you to provide alternate docroots
An example entry would look like :
<property name="alternatedocroot_1" value="from=*.jsp dir=path_to_directory"/>
Details here