Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache Tomcat 7 + Nginx - IsTomcat Native needed?

this is my 1st question. If i make mistake, simply point it out & i'll improve it next time. I'm a Java Dev & new to Linux. I deploy my Spring MVC app on a VPS with Tomcat 7 and use nginx as a proxy server. After surfing over Internet for days, I see it might be a good combination instead of using tomcat with apache. I'm going to learn more about what nginx can do. At the moment, nginx handle SSL from client, Tomcat locates in the same machine & plays as a backend server with HTTP connector (no SSL between Tomcat & Nginx). I'm also use limit_req module as a basic HTTP Flood protection. I'm also know about APR - Tomcat native library when using Tomcat as a web server. Whenever I start my tomcat, it said that my APRis not found.

  1. Do I need to install APR lib for Tomcat in this scenario (nginx + tomcat http connector) to speed up my server?
  2. Am I beneficial by using proxy cache img, css...
  3. Who handle static files with this configuration? If tomcat does, we need APR installed, right?
  4. is there a way to secure certain request pattern only (like login page) when using proxy?

my nginx conf:

server {
    listen  443 ssl;    
        server_name  domain;
    ssl on;
    ssl_certificate /etc/nginx/ssl/domain.crt;
    ssl_certificate_key /etc/nginx/ssl/domain.key;

    location / {
                proxy_pass http://localhost:8080;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarfed-For $proxy_add_x_forwarded_for;    
    }
}

server {
        listen      80;
        server_name domain;
        return 301 https://$server_name$request_uri;
}
like image 477
Toan Nguyen Huy Avatar asked Nov 13 '22 06:11

Toan Nguyen Huy


1 Answers

I'll try to answer your questions:

  1. libtcnative gives tomcat the ability to use native OS interfaces which can speed up operation system related tasks, so you don't need it but i would recommend it! Here's a good example config for tomcat behind nginx: http://wiki.razuna.com/display/ecp/Razuna+with+Nginx+as+a+front+end+server
  2. As far as i understand you have to give nginx a root directory so it can provide and cache static files and pass ajax calls to the tomcat
  3. should be answered with 1. and 2.
  4. i don't really understand the question..
like image 82
TekTimmy Avatar answered Nov 15 '22 05:11

TekTimmy