Hello,
this is driving me nuts.
My scenario is an apache2 and a tomcat with several webapps in it.
Actually, with apache+tomcat is working fine but I want to migrate to nginx to increase the performance and consume less resources.
This is one of the VirtualHost in apache:
<VirtualHost *:80>
ServerAdmin mail@gmail.com
ServerName webapp.com
ErrorLog logs/webapp-error_log
CustomLog logs/webapp-access_log common
ProxyPass / http://localhost:8081/DataFormSender/
ProxyPassReverse / http://localhost:8081/DataFormSender/
</VirtualHost>
In this case I need to redirect to http, but in others is https.
Webapps are done with J2EE, using spring security.
The problem is that nginx is unable to find static resources (images, css, js, ...) I tried everything but nothing worked.
To define the path of the resources I do this way:
<link href="<c:url value="/resources/css/generic.css" />" rel="stylesheet" type="text/css" />
The generated URL is correct, but is returning a 404 error message.
I understand that spring security is not the problem because the message is not 403.
This is the nginx translation of the apache virtualhost
server {
listen 80;
server_name webapp.com;
error_log logs/webapp-error_log warn;
allow all;
proxy_redirect / http://localhost:8081/DataFormSender/;
#
# This should be changed to whatever you config to real server.
#
root /var/tomcat/webapps/DataFormSender/resources;
log_format format_3 'common';
access_log logs/webapp-access_log format_3;
location / {
proxy_pass http://localhost:8081/DataFormSender/;
}
}
Any idea to solve this weird problem? Thank you for your time