I am in the process of switching from apache to nginx as reverse proxy as new knowledge has been gained around better resource usage of nginx. Since I have apache experience , it took me some time and research to figure out the root part of the following configuration.
server {
listen 80;
server_name test.myapp.localhost;
access_log /var/log/nginx/test.myapp.localhost_access.log;
error_log /var/log/nginx/test.myapp.localhost_error.log warn;
root /var/lib/tomcat7/webapps/ROOT;
location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
access_log off;
expires max;
}
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080;
}
}
This configuration without the root directive has issues showing images and I got to understand it's per design as I had to include the tomcat folder as root as well.
This works fine in the case where tomcat and nginx share the same server. What if nginx and tomcat are both on different servers. How files are rendered in that case.
Thanks for reading