The scheme is approximately as follows: There is example.com consisting of several applications - a website in php and java applications for a personal account. At the moment, the subdomain is configured for the account and everything works - there is one location that is proxied immediately to the java application.
location / { proxy_pass http://cabinet/; } But there was a need to remove the application from the subdomain and make access to the url: example.com/cabinet .
If you use the settings below, example.com/cabinet opens without styles and js. The fact is that in the java application itself there are paths of the form /static/jqery.js - for which it gives 404 and styles are not loaded. Part of the site on php works fine. Now links lead to php site example.com/static/script.js . Is it possible to do so that when entering /cabinet all links to static files are of the form example.com/cabinet/static/script.js ?
# Сервера с php приложением upstream php { ip_hash; server 192.168.100.20 max_fails=2 fail_timeout=360 weight=10; server 192.168.100.30 max_fails=2 fail_timeout=360; } # Сервера с java приложением upstream cabinet { ip_hash; server 192.168.100.101 max_fails=2 fail_timeout=360; } # Балансировщик, если запрашивают / - отправляет на php, если /cabinet - на java приложение server { listen 443 ssl; server_name example.com; ssl on; ssl_certificate /etc/nginx/ssl/site.ru.crt; ssl_certificate_key /etc/nginx/ssl/site.ru.key; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; location / { proxy_pass http://php; proxy_redirect off; proxy_set_header Host $host; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_503 http_504 http_502; proxy_connect_timeout 50; proxy_read_timeout 50; } location /cabinet { proxy_pass http://cabinet; proxy_redirect off; proxy_set_header Host $host; proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_503 http_504 http_502; proxy_connect_timeout 50; proxy_read_timeout 50; } } }