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 am trying to setup nginx with a reverse proxy to tracd, however I only want to use 1 tracd.

Now first here's my config for this domain

server {
    listen   80;
    server_name bugs.XXXXXXXX.com;

    access_log  /var/log/nginx/XXXXXXXX-bugtracker.access.log proxy;

    location / {
        rewrite ^/bugtracker/(.*)$ /$1;
        rewrite ^/bugtracker$ /;
        proxy_pass http://127.0.0.1:81/bugtracker/;
        proxy_redirect default;
        proxy_set_header Host $host;
    }

    location ~ /\.ht {
        deny  all;
    }
}

As you can see there's the rewrite rules, because for some reason all the urls that tracd spews out are like /bugtracker/something.

Now this is indeed caused by tracd just sending urls like it normally should however trac is at bugs.XXXXXXXX.com/ and not at bugs.XXXXXXXX.com/bugtracker. So how can I make tracd/trac display the (In this case) correct urls ?

share|improve this question

3 Answers 3

At work we have a project environment with lots of trac instances (each of them running as different user), so we can't afford to have WSGI processes running for all of them at the same time. Thus, i setup many apache+itk+suexec+fastcgi virtualhosts as the nginx proxy upstreams (each project has 1 virtualhost for trac and 1 virtualhost for svn).

We don't want to add 1 location in nginx for each trac and svn instance, so after spending several days fighting nginx proxy directives with regexes i found that there's a couple of options in trac.ini (since 0.10.5) that can be used to change the default redirect location.

In your case it should have been something like this:

base_url = http://bugs.XXXXXXXX.com/
use_base_url_for_redirect = True

And then the apache redirects (or tracd redirects in your case), should point to the public project URL, not trac default.

See http://trac.edgewall.org/wiki/TracIni for the more details.

share|improve this answer
location / {

        proxy_pass http://127.0.0.1:81/;
        proxy_redirect default;
        proxy_set_header Host $host;
    }
share|improve this answer
up vote 0 down vote accepted

I have switched to using the built in WSGI server as that is intended for a production environment and tracd is not.

it works fine and don't have the above issue that I would have with tracd.

share|improve this answer

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.