0

I have Two nginx containers one on port:80 and other on 88 . I want the application "App-A" to be my front facing and proxy_pass to application "App-B" when traffic hits to http:<IP_adress>/App-B/ . Both the applications work fine on 88 and 80 individually but when I try to proxy_pass to application B . css, and js files are been searched on application A root directory as shown in below picture . enter image description here

If I place those css and js files in first application it work's fine , but as both the application is independent, I can not place those files in the root directory on application-A. The below is my nginx.conf file

upstream backend {
    server Application-B; # fail_timeout=1s max_fails=1;

}
server
{
 listen 80 default_server;
    server_name localhost;
    return 301 https://$host$request_uri;

}
server
{
    listen 443 ssl default_server;

    server_name localhost;

    client_max_body_size 200M;

    ssl on;

    ssl_certificate         /etc/ssl/certs/cert2.crt;
    ssl_certificate_key                 /etc/ssl/certs/cert2.key;

    error_page   500 502 503 504  /50x.html;
    error_page   404 /404.html;

    location = /50x.html {
        root   /var/lib/nginx/ui2;
    }

    location = /404.html {
        root   /var/lib/nginx/ui2;
    }

    location / { ## for Application-A
      root   /var/lib/nginx/ui2;
        index  index.html index.htm;
    }

    location /Application-B/ {
      proxy_pass   http://backend/;
    }
 }

How to make nginx look for css and js file in Application-B but not in Application-A. At present its is looking in /var/lib/nginx/ui2 in Application-A container

  • This may help https://stackoverflow.com/questions/23776660/how-to-make-nginx-serve-static-content-like-js-css-html – umar Nov 11 '21 at 08:37

0 Answers0