how can i check if vhost is enabled on tomcat7 - tomcat7

I am trying to add a vhost to my already running tomcat7 server.
I already have my default application running on tomcat successfully.
<Host name="mydefault.com" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
<Host name="myNewHostDomain.com"
appBase="wings_microx_cash_reports"
unpackWars="true" autoDeploy="true">
i have added the domain as well on dns (godaddy) and ping is running fine.
But when i check the logs in /usr/share/tomcat7/logs, i do not see anyinfo with respect to my new vhost
Also, when i send in a http request to my new host, i see the default host app is running
<Engine name="Catalina" defaultHost="mydefault.com">
Any pointers how i can check/rectify this?

sorry for false alarm
i had not closed the tag pproperly.

Related

Impossible to display static images saved on tomcat server in a jsp after trying all context docBase configurations

Im unable to display an image uploaded by a user on my local server (D:\fichiers)in a JSP,
using pure Jee (no spring), Tomcat 9, intelli-j idea.
I've tried everything i could find :
I tried to add :
<Context docBase="D:\fichiers" path="/images"/>
in context.xml in meta-inf, in server.xml in Tomcat installation conf folder, in server.xml in Tomcat/conf of the app, in catalina/localhost/root.xml, in catalina/localhost/context.xml.
But i still get an error 404, images not found.
Here is the server.xml file :
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context docBase="D:\\fichiers" path="/images"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b"/>
</Host>
and the jsp call :
<c:set var="chemin">/images/</c:set>
<c:forEach items="${spot.photos}" var="photo">
<img src="${chemin}${photo.nom}"/>
</c:forEach>
The only time it worked is when i checked on tomcat configuration
Deploy applications configured in Tomcat instance
But i had to remove it, cause Catalina was starting springframework on its own, and nothing worked properly after that.
Ok i found the answer, and though it's stupidly simple, i couldn't find a place where it was said.
In Tomcat configuration tab in Intelli-j :
Deployment Tab -> Add external Source -> Select the local Drive -> Put URL desired in Application Context, and that's it !

Spring boot war package in tomcat webapps

My spring boot application.yml:
server:
port: 9999
servlet:
context-path: /test
and i put the war package in tomcat webapps
and my server.xml
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="/" docBase="test" debug="0" privileged="true" reloadable="true"/>
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
when i access the localhost:9999/test/index ,it does not work
What is the correct configuration?
as far as I can tell you have to change the port of the tomcat if you want to run it as localhost:9999/test/index 9999 should be the tomcat's port on which the webapp will respond

how to log requested path in access log?

We are using Jboos Eap 7.1 in our organization with access log enabled with the following pattern:
<access-log pattern="%h %l %u %t %r %s %b %{Referer}i %{User-Agent}i %{COOKIE}i %{SET-COOKIE}o %S %I %T"/>
Each 5 minutes server log says:
[org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver] (default task-49) Resolved [org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation]
But in access log we see:
GET /general-error.html HTTP/1.1 404
Which is a fallback page for errors, so we don't know which url or spring controller is being requested, how can I see actual requested path like nginx does?
You can configure Request logging / RequestDumping handler using following commands.
Create a new Expression Filter with the RequestDumping Handler
/subsystem=undertow/configuration=filter/expression-filter=requestDumperExpression:add(expression="dump-request")
Enable the Expression Filter in the Undertow Web Server
/subsystem=undertow/server=default-server/host=default-host/filter-ref=requestDumperExpression:add
Above commands will add the following configuration in domain.xml/standalone.xml in undertow subsystem
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https"/>
<host name="default-host" alias="localhost">
...
<filter-ref name="requestDumperExpression"/>
</host>
</server>
...
<filters>
...
<expression-filter name="requestDumperExpression" expression="dump-request"/>
</filters>
The output will be logged in server.log file.
Refer following url for more detail :
https://access.redhat.com/solutions/2429371

Tomcat 7 not auto unpacking war

I want to deploy my app as root app so I renamed my war to ROOT.war. Default server.xml looks like -
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
I also need to serve some static content. So I added Context tag-
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<Context docBase="/home/athakur/Documents/UI" path="/" />
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
I want to serve static content from this path and apis from my ROOT.war. But as soon as I add context element ROOT.war is not expanding and getting deployed. When I remove the context path it does. Also UI is correctly rendered from the path post adding context tag. So don't want to change that behavior either.
Looks like we cannot do this. We cannot have two context with same path and different docBase under same host. So you cannot have -
<Context docBase="/home/athakur/Documents/UI" path="/" />
<Context docBase="ROOT" path="/" />
So I had to settle for
<Context docBase="/home/athakur/Documents/UI" path="/" />
<Context docBase="ROOT" path="/apis" />
If you however want to do it at root level only then you need to do it from inside your webapp.
Docs - https://tomcat.apache.org/tomcat-8.0-doc/config/context.html

How to configure Tomcat7 server.xml Environment to take as value Network path?

I am trying to configure Tomcat7 serer.xml
the
<Host appBase="webapps/testweb" name="trythis.test.com" unpackWARs="true" autoDeploy="true">
<Context docBase="." path="" reloadable="false">
<Environment name="WEB_APP_PROPERTIES" type="java.lang.String" value="\\10.120.13.200\config"/>
</Context>
</Host>
Even though this config folder is accessible over the network my Tomcat can't access it:

Resources