简体   繁体   中英

How to point Tomcat 7 server.xml docbase residing in Amazon ec-2 instance to a folder in Amazon S3 bucket

In my local I am successfully able to point my docBase like this - <Context docBase="D:/XYZ" path="/video" /> .

Since my Java based application is going to be hosted on AWS, I am using Amazon ec2 to deploy my application and Amazon S3 to host the videos, thumbnails and profile photos of the users. So I changed my tomcat 7 server.xml entry on ec2 to <Context docBase="http://MyS3EndPointURL" path="/videos" />

However when I am trying to restart my tomcat, it errors out saying -

java.lang.IllegalArgumentException: Document base /usr/share/tomcat7/webapps/MyS3EndPointURL/Videos does not exist or is not a readable directory

I tried removing http:// but as I expected it didn't work as well.

I understand that I will have to give permission to Tomcat to have access to these folders, however I have these questions -

  1. How do I provide this access ?
  2. When a user uploads a video will my application have the write access to these folders ? If no, how to provide that ?

From whatever reference articles are available on AWS, none talks about this issue. Stackoverflow question searches are mostly outdated information or people are suggesting to have another static domain. I am supposed to release the product this weekend in BETA mode but I am stuck because of this issue. Any pointers, suggestions would just save me !

If I understand your setup, your app is hosted on Tomcat, you want your users to upload content to S3, so you can refer to your assets via an S3 http endpoint.

If so, your app server configuration is incorrect. Your server will not serve any videos itself; that job is offloaded to S3. Rather than define a docBase as you have, you will want to provide a URL rewrite rule so that http://www.example.com/videos/ point s to the new S3 http endpoint EG http://assets-example-com.s3-website-us-east-1.amazonaws.com/videos/ .

When a user uploads a video will my application have the write access to these folders ? If no, how to provide that.

If you have not already, you need to develop an upload interface with the appropriate permissions the the above bucket. See Java Upload File for more information

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM