LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-18-2016, 02:27 AM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Rep: Reputation: 177Reputation: 177
How to set default webapp for URL


I am using Apache Tomcat 8.0.15 on Linux Slackware 14.1. I have a server with multiple URLs. In $CATALINA_HOME/webapps I have separate app directories corresponding to each of these URLs.

How to I configure things so that a user just has to type the URL and gets the right app? For example:

enter: http://www.mydomain.com ---- instead of: http://www.mydomain.com/thisApp
 
Old 04-19-2016, 07:49 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by mfoley View Post
I am using Apache Tomcat 8.0.15 on Linux Slackware 14.1. I have a server with multiple URLs. In $CATALINA_HOME/webapps I have separate app directories corresponding to each of these URLs.

How to I configure things so that a user just has to type the URL and gets the right app? For example:

enter: http://www.mydomain.com ---- instead of: http://www.mydomain.com/thisApp
If you want to set thisApp as the default tomcat webapp, then you should (re)move the ROOT directory and then rename thisApp to ROOT.
Of course you need to restart tomcat afterwards.

Regards
 
Old 04-21-2016, 12:53 PM   #3
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
That doesn't really help. What would I do for the other URLs? They can't all be ROOT. I have several folders under $CATALINA_HOME/webapps:

thisgroup/
thatgroup/
anothergroup/

For each of these I have a corresponding public domain/URL

http://www.thisgroup.org
http://www.thatgroup.org
http://www.anothergroup.org

I'm also using Apache httpd, and have the following httpd-tomcat.conf

Code:
# Load mod_jk module
LoadModule    jk_module  lib64/httpd/modules/mod_jk.so

# Where to find workers.properties
JkWorkersFile /etc/httpd/workers.properties

# Where to put jk shared memory
JkShmFile     /var/log/httpd/mod_jk.shm

# Where to put jk logs
JkLogFile     /var/log/httpd/mod_jk.log

# Set the jk log level [debug/error/info]
JkLogLevel    info

# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

# Send everything for context /examples to worker named worker1 (ajp13)

JkMount  /thisgroup/* worker1
JkMount  /thisgroup worker1

JkMount  /thatgroup/* worker2
JkMount  /thatgroup worker2
I would think that the JkMount attribute would tell Tomcat where to go.

Also, I do have this already working for another website. All users have to do is type into their browser http://www.mydom.com and they get the webapp in $CATALINA_HOME/webapps/mydom (without even the .com at the end). I've looked through httpd.conf, workers.properties, httpd-tomcat.conf, web.xml, server.xml, and I cannot for the life of me see what is set to make this work. It must be something simple as I figured it out once (perhaps with help), but didn't write down the solution, probably because it seemed so obvious at the time.
 
Old 04-21-2016, 04:35 PM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by mfoley View Post
That doesn't really help. What would I do for the other URLs? They can't all be ROOT. I have several folders under $CATALINA_HOME/webapps:

thisgroup/
thatgroup/
anothergroup/

For each of these I have a corresponding public domain/URL
Think about this.
What happens if we just type http://your_server_ip ?
What should we get?
 
Old 04-22-2016, 01:14 AM   #5
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Quote:
Originally Posted by Habitual View Post
Think about this.
What happens if we just type http://your_server_ip ?
What should we get?
Not sure I get what you're asking, but here's the real-world example (a public site, so not a problem). The one that works is http://www.cantleysauto.com. Type that in and you get right to the website. The .jsp programs for this site are located in $CATALINA_HOME/webapps/cantleys/

That's what I'm trying to re-create! Sadly, I forget how I accomplished that.

The IP for that site is 108.66.178.143. typing in http:/108.66.178.143 gives a 403 error from Tomcat ... but I'm not sure why that's interesting. Explain?
 
Old 04-22-2016, 05:20 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
The one that works is http://www.cantleysauto.com. Type that in and you get right to the website. The .jsp programs for this site are located in $CATALINA_HOME/webapps/cantleys/

That's what I'm trying to re-create! Sadly, I forget how I accomplished that.
This is an apache web server acting as a reverse proxy for the tomcat server running the cantleys webapp.
So, take a look at the apache vhost config file to see how the vhost www.cantleysauto.com is configured and do the same for the rest of your webapps and vhosts

Regards
 
Old 04-22-2016, 11:35 AM   #7
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Quote:
Originally Posted by bathory View Post
This is an apache web server acting as a reverse proxy for the tomcat server running the cantleys webapp.
So, take a look at the apache vhost config file to see how the vhost www.cantleysauto.com is configured and do the same for the rest of your webapps and vhosts

Regards
I thought of that, but httpd-vhosts.conf is not configured or included in httpd.conf

No <VirtualHost>'s configured in httpd.conf
 
Old 04-22-2016, 03:22 PM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by mfoley View Post
I thought of that, but httpd-vhosts.conf is not configured or included in httpd.conf

No <VirtualHost>'s configured in httpd.conf
If there are no vhosts defined, then I guess that each of your sites (http://www.thisgroup.org, http://www.thatgroup.org. http://www.anothergroup.org, etc) is served by a different apache installation and thus they are all listening on different IPs.
Can you verify that the 3 websites above are configured on different IPs?
 
Old 04-23-2016, 12:21 PM   #9
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Quote:
Originally Posted by bathory View Post
If there are no vhosts defined, then I guess that each of your sites (http://www.thisgroup.org, http://www.thatgroup.org. http://www.anothergroup.org, etc) is served by a different apache installation and thus they are all listening on different IPs.
Can you verify that the 3 websites above are configured on different IPs?
I don't have the 3 sites configures yet. Only one. I'm trying to get this one going first. In the end, they will all have the same IP. Why can't I get the one site working with URL only and no app folder reference? I have exactly that working with cantleys site I referenced:

Here are all the configs for the cantleys site -- maybe something in there explains why this works:

httpd.conf (LoadModule not included)
Code:
ServerRoot "/usr"

Listen 80


Include /etc/httpd/extra/tomcat.conf

<IfModule unixd_module>
User cantleys
Group cantleys

</IfModule>

ServerAdmin mfoley@novatec-inc.com

ServerName www.cantleysauto.com

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

DocumentRoot "/usr/local/apache/htdocs"

<Directory "/usr/local/apache/htdocs">
    Options Indexes FollowSymLinks

    AllowOverride All

    Order allow,deny
    Allow from all
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "/usr/local/apache/logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{User-Agent}i\"" marks

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "/usr/local/apache/logs/access_log" marks

</IfModule>

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/srv/httpd/cgi-bin/"

</IfModule>

<IfModule cgid_module>
</IfModule>

<Directory "/usr/local/apache/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig /etc/httpd/mime.types

   AddType application/x-compress .Z
   AddType application/x-gzip .gz .tgz

</IfModule>

<IfModule proxy_html_module>
Include /etc/httpd/extra/proxy-html.conf
</IfModule>

<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
extra/proxy-html.conf
Code:
ProxyHTMLLinks  a               href
ProxyHTMLLinks  area            href
ProxyHTMLLinks  link            href
ProxyHTMLLinks  img             src longdesc usemap
ProxyHTMLLinks  object          classid codebase data usemap
ProxyHTMLLinks  q               cite
ProxyHTMLLinks  blockquote      cite
ProxyHTMLLinks  ins             cite
ProxyHTMLLinks  del             cite
ProxyHTMLLinks  form            action
ProxyHTMLLinks  input           src usemap
ProxyHTMLLinks  head            profile
ProxyHTMLLinks  base            href
ProxyHTMLLinks  script          src for

ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \
                onmouseover onmousemove onmouseout onkeypress \
                onkeydown onkeyup onfocus onblur onload \
                onunload onsubmit onreset onselect onchange
extra/tomcat.conf
Code:
LoadModule    jk_module  lib64/httpd/modules/mod_jk.so

JkWorkersFile /etc/httpd/workers.properties

JkShmFile     /var/log/httpd/mod_jk.shm

JkLogFile     /usr/local/apache/logs/mod_jk.log

JkLogLevel    info

JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
workers.properties
Code:
worker.list=cantleys

worker.cantleys.type=ajp13
worker.cantleys.host=localhost
worker.cantleys.port=8009
worker.cantleys.mount=/ /*
server.xml (diff from as-shipped version)
Code:
> diff server.xml-org  server.xml
139a140,154
>
>       <Realm className="org.apache.catalina.realm.MemoryRealm" />
>
>       <Host name="www.cantleysauto.com" appBase="webapps"
>             unpackWARs="true" autoDeploy="true"
>             xmlValidation="false" xmlNamespaceAware="false">
>
>             <Alias>cantleysauto.com</Alias>
>             <Logger className="org.apache.catalina.logger.FileLogger" directory="logs/" prefix="cantleysauto_access_log" suffix=".log" timestamp="true"/>
>
>           <Context path="" docBase="cantleys" reloadable="false" allowLinking="true">
>             <WatchedResource>/WEB-INF/web.xml</WatchedResource>
>           </Context>
>       </Host>
I've check these configs on the working host with the ones on the host I'm trying to get work and I can't see any difference. I'll check again.
 
Old 04-23-2016, 12:30 PM   #10
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
WAIT A MINUTE!!! It seems to be working now. Did I fix something? Did I merely refresh the browser? No idea. Now, to move onto the next step -- multiple sites to the same IP. I'll test than and post back.
 
Old 04-23-2016, 01:14 PM   #11
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by mfoley View Post
WAIT A MINUTE!!! It seems to be working now. Did I fix something? Did I merely refresh the browser?
Might have been cached in the browser. a forced Reload (Shift+Reload button) on the page in Firefox always forces cache to be refreshed with
fresh content from the server.
 
  


Reply

Tags
tomcat



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
(SOLVED)Tomboy Notes: How to set URL to default browser? bobww99 Linux - Software 3 10-01-2014 11:15 AM
Finding Default Lenny Source URL's? carlosinfl Debian 5 07-19-2007 09:44 AM
By default is url file access disabled? got_nix Linux - Server 6 07-04-2007 10:46 AM
Open an URL in the default browser guasqui Programming 2 03-22-2006 11:54 AM
(alt+f) + enter url default location ergo_sum Linux - Newbie 2 09-18-2003 01:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration