You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Martin Moore <ma...@gmail.com> on 2023/09/15 18:48:17 UTC

How to setup Apache web server for a Tomcat deployed Spring application

Hello,

I have a situation where I want to call an Tomcat deployed Spring
application remotely without adding the port number (8080), I had tried to
use 80 in Connector but wasn't able to connect to it when outside the LAN.
So I resorted to creating a proxy server using Apache2 Web Server (along
side the Tomcat application server).

Unfortunately when I call the app using name1.domain.com/app/login it times
out and fails.
Following are the configuration for Apache2 and Tomcat:
In server.xml (Tomcat V8)
    <Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="443"
               proxyName="name1.domain.
<http://qadat.qfls.idealab.unical.it/>com"
               proxyPort="80"
  />

httpd.conf (under conf/ in Apache2)
...
LoadModule proxy_module modules/mod_proxy.so
...
ServerName  name1.domain. <http://qadat.qfls.idealab.unical.it/>com:80
<http://qadat.qfls.idealab.unical.it/>
<VirtualHost *:80>
   ProxyPass /app/login http://localhost:8080/app/login
<http://localhost:8080/qadat/login>
   ProxyPassReverse /app/login http://localhost:8080/app/login
<http://localhost:8080/qadat/login>
</VirtualHost>

To note that on the local machine tomcat returns the app through
http://localhost:8080/app/login <http://localhost:8080/qadat/login>

How to make the app requests proxied so that name1.domain.
<http://qadat.qfls.idealab.unical.it/>com/app/login works and calls the
localhost:8080/app/login to return the Tomcat Spring app

To note that DocumentRoot was added and then removed and that the app
resides in webapps/ROOT

Thanks.

Re: How to setup Apache web server for a Tomcat deployed Spring application

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Martin,

On 9/15/23 14:48, Martin Moore wrote:
> I have a situation where I want to call an Tomcat deployed Spring
> application remotely without adding the port number (8080), I had tried to
> use 80 in Connector but wasn't able to connect to it when outside the LAN.

What's the motivation, here? It may allow for more flexible solutions. 
Are you trying to use non-8080, or are you trying to use non-secure, or 
both?

> So I resorted to creating a proxy server using Apache2 Web Server (along
> side the Tomcat application server).
> 
> Unfortunately when I call the app using name1.domain.com/app/login it times
> out and fails.
> Following are the configuration for Apache2 and Tomcat:
> In server.xml (Tomcat V8)
>      <Connector port="8080" protocol="HTTP/1.1"
>                 connectionTimeout="20000"
>                 redirectPort="443"
>                 proxyName="name1.domain.
> <http://qadat.qfls.idealab.unical.it/>com"
>                 proxyPort="80"
>    />
> 
> httpd.conf (under conf/ in Apache2)
> ...
> LoadModule proxy_module modules/mod_proxy.so
> ...
> ServerName  name1.domain. <http://qadat.qfls.idealab.unical.it/>com:80
> <http://qadat.qfls.idealab.unical.it/>
> <VirtualHost *:80>
>     ProxyPass /app/login http://localhost:8080/app/login
> <http://localhost:8080/qadat/login>
>     ProxyPassReverse /app/login http://localhost:8080/app/login
> <http://localhost:8080/qadat/login>
> </VirtualHost>

Looks good so far, except I would put trailing / symbols on here:

      ProxyPass /app/login/ http://localhost:8080/app/login/
      ProxyPassReverse /app/login/ http://localhost:8080/app/login/

Your email program seems to have put links into hostnames that makes 
this a little difficult to interpret.

> To note that on the local machine tomcat returns the app through
> http://localhost:8080/app/login <http://localhost:8080/qadat/login>
> 
> How to make the app requests proxied so that name1.domain.
> <http://qadat.qfls.idealab.unical.it/>com/app/login works and calls the
> localhost:8080/app/login to return the Tomcat Spring app
> 
> To note that DocumentRoot was added and then removed and that the app
> resides in webapps/ROOT

If you are using the ROOT web app, then you should be proxying / and not 
/app/login/ (unless you really expect to proxy exactly one URL). Is the 
app called 'app' or 'qadat'?

If you want to refer to your application as /app/ then you should deploy 
it at webapps/app

What URL are you actually typing into the browser URL bar?

-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org