Uncategorised

Install tomcat app behind nginx

Posted

Tomcat in server.xml:

<Connector port=”8080″ protocol=”HTTP/1.1″ address=”localhost”
maxThreads=”150″
connectionTimeout=”20000″
proxyName=”my-host-name”
proxyPort=”443″
scheme=”https”/>

Application should be installed on tomcat at path “my-app” (copy my-app.war to tomcat/webapps)

 

Nginx in nginx.conf:

server {
listen 80;
server_name my-host-name;
return 301 https://my-host-name;
}

server {
listen 443 ssl;
server_name my-host-name;

ssl_certificate /usr/local/etc/nginx/my-host-name.crt;
ssl_certificate_key /usr/local/etc/nginx/my-host-name.key;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout 30m;

ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
rewrite ^ https://my-host-name/my-app/ redirect;
}

location /my-app/ {
proxy_read_timeout 60m;
proxy_pass http://localhost:8080/my-app/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;

}

}

Leave a Reply

Your email address will not be published. Required fields are marked *