nmpg
nmpg

Reputation: 601

Nginx Serving static from spring boot war

I built a spring boot application, I have thus one app.war file that contains an embedded tomcat and my application itself.

Here's my nginx config:

server {
    listen 80;
    server_name sub.domain.com;

    location / {
            proxy_pass http://127.0.0.1:8090/index;
    }

    location ~* \.(js|jpg|png|css|html|gif|pdf)$ {
            root /path/to/app/app.war
            expires 30d;
    }
}

The site is up an running at sub.domain.com, however the static content is not loaded..

How can I make this work?

Upvotes: 2

Views: 3422

Answers (1)

nmpg
nmpg

Reputation: 601

Made it work, easy enough

server {
    listen 80;
    server_name sub.domain.com;

    location / {
            proxy_pass http://domain.com:8090/;
    }

    location ~* \.(svg|js|jpg|png|css|html|gif|pdf)$ {
            proxy_pass              $scheme://domain.com:8090/$request_uri;
            proxy_redirect  off;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        Host $http_host;
            expires 30d;
    }
}

Hope it helps :)

Upvotes: 1

Related Questions