• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

Apache forwarding all requests to tomcat

 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have RHEL server and Apache  is forwarding all http(s) requests to tomcat server. This was deliberately done by someone else to make few things work. I want to filter some URLS and wondering how should I go about it? By filter I mean, let's say I want to access Apache ActiveMQ using the following URL : http://myservername.com:8161/admin , it should not get forwarder to tomcat. Is there a way I could do this in, maybe in SSL conf?
 
Saloon Keeper
Posts: 21981
150
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Usually the easiest way to ensure that different requests go to different apps (whether all on the same server or on multiple backend servers) is to define an Apache VirtualHost.

So, for example, virtualhost tomcatapp.coderanch.com might go to a Tomcat cat application but mqserver.coderanch.com would route to the MQServer. You can have Apache listen on any port(s) you like, and forward to any ports you like. Each virtualhost can share a port with other virtual hosts (especially ports 80 and 443).
 
Jack Tauson
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:Usually the easiest way to ensure that different requests go to different apps (whether all on the same server or on multiple backend servers) is to define an Apache VirtualHost.

So, for example, virtualhost tomcatapp.coderanch.com might go to a Tomcat cat application but mqserver.coderanch.com would route to the MQServer. You can have Apache listen on any port(s) you like, and forward to any ports you like. Each virtualhost can share a port with other virtual hosts (especially ports 80 and 443).



Thanks. So does this virtualhost thing needs to happen inside SSL conf of Apache? I haven't done anything like this before and hence wondering about it. Thanks !
 
Sheriff
Posts: 21922
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can (probably) also do this with one host. Just use a <Location> (or <LocationMatch>) element in your Apache configuration, and define the custom routing there. Note that the location matters, at least if you're using multiple <Location> and/or <LocationMatch> elements - as far as I know, they are evaluated from top to bottom.
 
Tim Holloway
Saloon Keeper
Posts: 21981
150
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can, but if they are different apps, I wouldn't do it that way. A VirtualHost is easier and simpler.

The only real problem with VirtualHost is if the client runs HTTP version 1.0, which didn't allow multiple hostnames for the same IP address. But that's a protocol that's probably been dead for 15 years.
 
Rob Spoor
Sheriff
Posts: 21922
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another issue may be SSL certificates. Those may not be available for a wildcard domain, and not every company feels comfortable using Let's Encrypt.
 
Tim Holloway
Saloon Keeper
Posts: 21981
150
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Rob Spoor wrote:Another issue may be SSL certificates. Those may not be available for a wildcard domain, and not every company feels comfortable using Let's Encrypt.



If it's important enough to need an SSL cert and Let'sEncrypt isn't an option, there's no reason for not getting a server cert for a virtualhost. It's not like Apache only supports 1 cert per instance.

Actually, I use LetsEncrypt and I do not have myself set up for wildcard certs. Each of my proxied virtual hosts has its own distinct cert.
 
Jack Tauson
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:Yes you can, but if they are different apps, I wouldn't do it that way. A VirtualHost is easier and simpler.

The only real problem with VirtualHost is if the client runs HTTP version 1.0, which didn't allow multiple hostnames for the same IP address. But that's a protocol that's probably been dead for 15 years.



When you say "if the client runs HTTP version 1.0, which didn't allow multiple hostnames for the same IP address", did you mean to say browser? Trying to understand what client you are referring here. Thanks !
 
Tim Holloway
Saloon Keeper
Posts: 21981
150
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Client" is whatever remote application is making requests to the Server. Generally this will be a web browser, but a command-line client application is often used to request web services. For example, I have a client that runs as an OSGi process and once a day, it pulls information from the National Hurricane Center and formats it for me to look at later. I also have weather-sensing equipment that uses short-range radio to a receiver which then posts the observations to a webapp which can display them and keep a history in a database. Another client is a wall-mounted e-paper display device that retrieves and displays some of that information, as well as the daily weather forecast.
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic