I am running apache tomcat in a remote server, I have a domain with sub-domains. I want to assign each sub-domain with a separate project. I am unable to run apache on other domain except localhost. The domain is bind to the remote server IP Address so all sub-domains refers to all projects in webapps folder not one specific.
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" 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>
<Host name="https://web-dev.example.com/" appBase="web-dev.example.com"
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>
</Engine>
The name attribute of your host should contain the DNS name of the virtual host:
Usually the network name of this virtual host, as registered in your Domain Name Service server. Regardless of the case used to specify the host name, Tomcat will convert it to lower case internally.
(cf. Tomcat documentation).
Therefore you should use:
<Host name="web-dev.example.com"
appBase="web-dev.example.com">
...
</Host>
(I omitted the attributes with default values).
Related
i try to set my domain as vhost.
My config looks like this:
<Host name="example.de" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Alias>www.example.de</Alias>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="example_access" suffix=".log"
pattern="%h %l %u %t "%r" %s %b" />
<Context path="" docBase="/opt/tomcat/webapps/app1" debug="0" reloadable="true" />
</Host>
This config works with every subdir in the webapps-directory, except for the directory I want. If I try to open the Domain, there is an empty browsertab. (Error 404) But if I call it like www.example.de/app1, the app still works and everything ist fine :/
I don't have any idea :/
PS: It's a clean setup of Tomcat, just extracted and edited the server.xml for the vHost-settings
Remember to deploy every application you'd like to appear in a virtual host, including the ROOT application. If you don't have a ROOT application, there is no "default" application that Tomcat can fall-back to, and your clients will get 404 responses when requesting /.
This question already has answers here:
Deploying my application at the root in Tomcat
(10 answers)
Closed 8 years ago.
I tried to deploy my application file to Tomcat 7. I have successfully deployed them, but I can see my files only under http://example.com:8080/myproject/index. (Assume that my project folder is myproject and my domain is example.com.)
I would like to to access to my domain like this: http://example.com/index.
How can I do that?
ok
I have solved the problem.
in the default server.xml file tag like this,
<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>
but I have removed that and changed like these
<Host appBase="webapps" name="example.com" unPackWars="true" autoDeploy="true">
<Context path="" docBase="myproject" debug="0" reloadable="true"/>
</Host>
<Host appBase="webapps" name="www.example.com" unPackWars="true" autoDeploy="true">
<Context path="" docBase="myproject" debug="0" reloadable="true"/>
</Host>
and than I have changed
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
like this
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
now it works:)
C:\asset (there I have images like 1.jpg / 2.jpg / 3.jpg etc)
My tomcat server.xml looks like this:
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Context path="/test" docBase="C:/asset" debug="0" reloadable="true" crossContext="false"/>
<!-- 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>
Still when i go to localhost:8080/test/1.jpg I have 404 error any ideas why this don't work ?
Another question is there any possibility to configure this path in my spring project ? As a variable ?
Somehow I cannot normally map domain to my webapp in tomcat7.
Here is the parts from server.xml:
<Engine name="Catalina" defaultHost="localhost">
<Host name="mydomain.com" appBase="webapps" autoDeploy="true" unpackWARs="true">
<Alias>www.mydomain.com</Alias>
<Context path="" docBase="myapp"/>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
Does the defaultHost must be localhost or mydomain.com?
I have written a script which deploys myapp in ubuntu:
#!/bin/bash
service tomcat7 stop
rm -rf /usr/share/tomcat/webapps/myapp/
cp myapp.war /usr/share/tomcat/webapps/
service tomcat7 start
After running this script I can access my app only like this: mydomain.com/myapp
If I restart tomcat then it maps to the domain ok, but there is two webapps running.
What am I doing wrong?
To make your web application the default webapp you can simply
rename your myapp.war to ROOT.war,
rm -r /usr/share/tomcat/webappas/ROOT
cp ROOT.war /usr/share/tomcat/webapps
more information available at: http://wiki.apache.org/tomcat/HowTo#How_do_I_make_my_web_application_be_the_Tomcat_default_application.3F
I have a Java based web application which is deployed on Ubuntu machine. I can access the web application at localhost:8080 and it is working as expected.
Now I have domain name for the web application and I want to access web application through the browser using the domain name(http://www.xyz.com).
I want to know the steps which are required to achieve it. Before posting this question, I search over the google.
I have already added the host details in the conf/server.xml.
<Host name="xyz.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Alias>www.xyz.com</Alias>
<Context path="" docBase="" debug="0" privileged="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
Also, I made changes in the /etc/hostname and added following
<IP Address> www.xyz.com xyz
What else do I need to do?