Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have multiple webapps on a server, each on a seperate port:


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_redirect /mywebapp1/;


This loads the HTML of the first page of the webapp. But no CSS, images and anything else. Where is my fault?

share|improve this question
Check the text of the first page. It will include references to the missing CSS and image files. I think, there will be wrong URLs there, from which you'll decipher what went wrong. – minaev Dec 18 '11 at 13:38

You have to use this block:

location /mywebapp1 {
   rewrite /mywebapp1(.*)$ $1 break;

proxy_redirect will send to your browser HTTP code 301, permanent redirect to, which is not your intence.

share|improve this answer
rewrite /mywebapp1(.*)$ $1 break; gave me an Error 500. Change it to rewrite /mywebapp1/(.*)$ $1 break; solves the Error 500, but now the site looks same: no images, no css. It looks like the browser tries to load css from, which does not work. – Thomas Deutsch Dec 16 '11 at 10:30
@ThomasDeutsch: Try to inspect the source code of your loaded web page, if there is not a URL's with address – Jan Marek Dec 19 '11 at 12:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.