I have multiple webapps on a server, each on a seperate port:
http://localhost:8080
http://localhost:8081
Now, I've tried to use nginx in the front as a proxyserver. Goal is, to use webapps.local.domain/mywebapp1 and webapps.local.domain/mywebapp2 instead of above URLs. I tried this, but it did'nt worked:
server {
listen 80;
server_name webapps.local.domain;
access_log /var/log/nginx/webapps.local.domain-access.log;
location /mywebapp1 {
proxy_pass http://127.0.0.1:8080;
proxy_redirect http://127.0.0.1:8080 /mywebapp1/;
}
}
This loads the HTML of the first page of the webapp. But no CSS, images and anything else. Where is my fault?
Best Answer
You have to use this block:
proxy_redirect will send to your browser HTTP code 301, permanent redirect to 127.0.0.1:8080, which is not your intence.