I want to use same url with virtual location to access from web browser to my apps. For example:
- samedomain.com/app1
- samedomain.com/app2
I'm using ubuntu server 20.04 and Nginx for deploy my .Net Core apps, the document root for app1 is /var/www/app1/wwwroot,the document root for app2 is /var/www/app2/wwwroot. My problem is serve the css, images and js archives for each app... this is my nginx configuration:
upstream app1 {
server 192.168.1.1:5003;
}
upstream app2 {
server 192.168.1.1:5004;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name apps.domain.com;
root /var/www/apps;
location / {
try_files $uri $uri/ /index.html;
proxy_read_timeout 300s;
proxy_connect_timeout 75s;
}
location /app1/ {
proxy_pass http://app1/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /app2/ {
proxy_pass http://app2/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
#Static Archhives
#location ~* \.(js|css|svg|jpg|png)$ {
# root /var/www/app1/wwwroot;
# expires 24h;
# }
}
whith the last part of my nginx configuration, only app1 can load statics files, not load the icons from font awesome, app2 can't load anything...
#Static Archhives
#location ~* \.(js|css|svg|jpg|png)$ {
# root /var/www/app1/wwwroot;
# expires 24h;
# }
}
somebody know how can i serve css, js, jpg files to each app?
Thanks in advance