Hello, this is driving me nuts. My scenario is an apache2 and a tomcat with several webapps in it. NOTE: the word http has a blank space in the middle because when I try to post the trhead is checking if url is working or not. 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 ServerName webapp.com ErrorLog logs/webapp-error_log CustomLog logs/webapp-access_log common ProxyPass / ht tp://localhost:8081/DataFormSender/ ProxyPassReverse / ht tp://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 / ht tp://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 ht tp://localhost:8081/DataFormSender/; } } Any idea to solve this weird problem? Thank you for your time
Ok, I found a partial solution: server { listen 80; server_name mdd.cat; rewrite ^/MyApp/(.*)$ /$1 last; 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 ht tp://127.0.0.1:8081/MyApp/; } } Now, is finding static resources, but when I try to login in my app is always displaying the login page. This is the url to access to login page: ht tp://mdd.cat/login And this is the url after successful login: ht tp://mdd.cat/login;jsessionid=8E1070C32C43260F294D1350233A06FA Any idea why its happening this? Thanks!!