• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Apache with Tomcat Authentication

 
p gro
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI i have an jee application which runs on a tomcat 7. It uses Spring Security for authentication. The JSF Application should deliver Images in the webpages.

I think it would be nice if apache would deliver these image files.

i have a main directory for medias. Every user has a subdir (his username) with his images.

so when the user requests "http://example.com/media/image.jpg" he should receive /srv/media/username/image.jpg

is there any possibility how apache could access the username on tomcat (maybe with the sessionid from the header). something like mod_auth_mysql is not a solution because there is no db with users, tomcat receives them from another server

any ideas?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it highly likely that you will be called upon to justify your use of "p gro" as a display name as opposed to something that looks more like a real person's name.

However.

Normally, I wouldn't recommend using Apache to serve up images for a Tomcat application these days. It has long since not been true that Apache can serve images significantly faster than Tomcat. However, if I'm reading correctly, you are looking to have the images come from user directories, not from a central application image directory.

Regardless, this is still something that Tomcat can probably do better than Apache, since Tomcat knows the user's identity and Apache does not. What I would do for the case mentioned above is to create a standard image servlet that opens an image file and copies it out to the HttpResponse output stream in the usual way, except that the logic that locates the image file that will be opened and read should synthesize the file path using the webapp username.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic