Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm running nginx 0.8.44, and I have two uwsgi (0.9.5.4) instances. One for my Django site, the other is running Trac.

I have Django setup as location / { ... }, and Trac is location /trac { ... } But When I go to http://mysite/trac, it gives Trac the /trac part of the url. So I basically get a 404 because Trac is looking for a url under it's root that is /trac. The page it goes to says

Error: Not Found
No handler matched request to /trac

And the CSS stylesheets aren't working on that page. But the typical parts of Trac are there like the "View Tickets" and "Wiki" links.

But if I change Trac's location to /, it works perfectly. Is there some way in either nginx or uwsgi to not send the "location" part of the url to application? This also happens to Django if it's location isn't /.

I was previously using Apache with mod_wsgi, and it was able to do this without any fuss.

share|improve this question
    
Please give detailed description of "location / { ... }" and "location /trac { ... }" you've configured. –  Ivan Chuchman Jul 11 '10 at 8:46
    
> "I was previously using Apache with mod_wsgi..." Have you tried nginx mod_wsgi? –  Ivan Chuchman Jul 11 '10 at 8:57

2 Answers 2

up vote 0 down vote accepted

I ended up setting up subdomains.
So for trac, I'm using trac.mydomain.com.

I did not find a way to do this without subdomains, but it might be possible. This just ended up being the easiest.

For anyone reading this, you need to add any subdomains to your DNS. And for nginx configuration you use something like this:

http {

   upstream django {
       ip_hash;
       server 127.0.0.1:3030;
   }

   upstream trac {
       ip_hash;
       server 127.0.0.1:3031;
   }

   server {
      listen 80;
      server_name mydomain.com;

      location / {
          uwsgi_pass django;
          include uwsgi_params;
      }
   }

   server {
       listen 80;
       server_name trac.mydomain.com;

       location / {
           uwsgi_pass trac;
           include uwsgi_params;
       }
   }
share|improve this answer

For those searching,

with fastcgi (and, I suppose, in a similar way for wsgi) it can also be done this way, similar to http://wiki.nginx.org/FcgiZope:

location /trac {
    fastcgi_pass unix:/path/to/socket;
    if ($uri ~ ^/trac/(.*)) {
        set $path_info /$1;
    }

    include fastcgi_params;
    fastcgi_param  SCRIPT_NAME        "/trac";
    fastcgi_param  PATH_INFO          $path_info;
}

; or, without an extra if:

location ~ ^/trac(?<path_info>/.*)$ {
    fastcgi_pass unix:/path/to/socket;
    include fastcgi_params;
    fastcgi_param  SCRIPT_NAME        "/trac";
    fastcgi_param  PATH_INFO          $path_info;
}

.

share|improve this answer
    
You could also replace the if with rewrite ^/trac(.*) $1 break; –  kolbyjack May 14 '11 at 13:50

Your Answer

 
discard

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.