2

I'm dropping Apache as a reverse proxy to a Tomcat instance, mainly because it has no other purpose other than forwarding requests to the Tomcat instance.

I'm no expert at deploying Java Web applications with Tomcat and I'm wondering if I'm running in for a nasty surprise if I use Nginx to forward requests to the HTTP connector?

Filip Dupanović
  • 155
  • 1
  • 1
  • 8
  • See also recent [Connect to a Tomcat Server from nginx as reverse proxy](https://serverfault.com/questions/771658/connect-to-a-tomcat-server-from-nginx-as-reverse-proxy) – Vadzim Dec 07 '17 at 20:04

2 Answers2

3

Yeah, that'll work just fine.

From the tag, I'm guessing you're using an AJP connector right now? You'll just need to make sure that your HTTP listener is working right; otherwise, there should be no problem. Nginx works great as a reverse proxy.

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • Yeah, your right, thanks. I was previously communicating via AJP and I had concerns about sessions and response headers, but everything seems to be working fine--faster even! – Filip Dupanović Apr 08 '11 at 08:48
2

Shouldn't run into any problems. I have that setup right now. Here's a modified version nginx conf that shows it's pretty straightforward.

server {
        listen      80;
        server_name server.example.com;
        rewrite     ^(.*)   https://$server_name$1 permanent;
}

server {
        listen   443;

        server_name  server.example.com server;

        ssl  on;
        ssl_certificate  /certs/ssl.crt;
        ssl_certificate_key  /certs/ssl.key;

        ssl_session_timeout  5m;

        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers   on;


        access_log  /var/log/nginx/access.log;

        location / {
            proxy_pass  http://127.0.0.1:8080/;
            proxy_redirect     off;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

            client_max_body_size       10m;
            client_body_buffer_size    128k;

            proxy_connect_timeout      90;
            proxy_send_timeout         90;
            proxy_read_timeout         90;

            proxy_buffer_size          4k;
            proxy_buffers              4 32k;
            proxy_busy_buffers_size    64k;
            proxy_temp_file_write_size 64k;
        }
}
photoionized
  • 464
  • 2
  • 6