简体   繁体   中英

How to secure access of a servlet?

I have a servlet running in my server Tomcat (A) and I want to restrict the access of this servlet.

If the request to access this secure servlet will come only from my server then only any one can access this servlet. If request will come from another Tomcat (B), then the request can't go to the servlet.

If some one want to make a ajax call and want to access my servlet then also they can't able to access my servlet.

How can I achieve this?

Best way to do this is to place this logic outside of your application or tomcat. Separate the concerns: your application handles business logic and another component handles security.

Most often nginx is used as a gateway between the outside world and your application where you can configure who can access what.

This is generally applicable independently on which technology you would use for your business logic.

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