I have a centos7 vm in which I deployed two spring services : tasklist (8082) and operate (8081), those two services are available via browser (I can go to http://[host-ip]:8081 (host-ip : vm ip address) via my browser and get access to the application) :
but when I tried to reverse proxy those ports (8081 & 8082) I can not get access to the static content when I inspect I got those errors :
here is my nginx configuration :
server{
listen 445;
listen [::]:445;
location /operate/ {
rewrite ^/operate/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8081;
}
location /tasklist/ {
rewrite ^/tasklist/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8082;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Convert it like this:
location ~ ^/operate/(.*)$ {
proxy_pass http://127.0.0.1:8081/$1;
}
location ~ ^/tasklist/(.*)$ {
proxy_pass http://127.0.0.1:8082/$1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /static {
root /var/www/html/static; # Adjust to your actual folder
}