0
votes

I have Nginx in front of Tomcat, but with proxy_pass static files are not served. Here is my config:

upstream tomcat {
server 127.0.0.1:8080 fail_timeout=0;
}

server {
    listen 80 ;
    listen [::]:80 ;
    index index.html index.htm index.nginx-debian.html;
    server_name example.com; # managed by Certbot   

    location / {
            try_files $uri $uri/ =404;
            proxy_pass http://127.0.0.1:8080/example/login;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Forwarded-Port $server_port;
    }

    location /css {
            root /var/lib/tomcat7/webapps/example/assets/theme/css/;
    }

If I go to https://example.com I'm getting the Tomcat app without CSS, images.

From the error.log

2019/02/07 16:14:27 [error] 17098#17098: *3 open() "/var/lib/tomcat7    /webapps/example/example/assets/css/main.css" failed (2: No such file or directory), client: 192.168.1.2, server: example.com, request: "GET /example/assets/css/main.css HTTP/1.1", host: "example.com", referrer: "https://example.com/"
1

1 Answers

0
votes

I fix it with:

location /example/assets/css {
            root /var/lib/tomcat7/webapps/example/assets/css;
            proxy_pass http://127.0.0.1:8080/example/assets/css;
}