Enabling Trac Behind Nginx

281 views
Skip to first unread message

David Philipe Gil

unread,
Dec 30, 2015, 10:46:00 PM12/30/15
to Trac Users
Greetings all, I am a fast-learning-newbie on the Linux scene and started with hosting my own web server. I now host my own Drupal blog from my home. I was asked to setup a bug database for a software I am working on so I am trying to get this working.

I want to use Trac through Nginx.

Here are tutorials on what I have done so far:

Starting My Own Nginx Webserver:
http://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/1/

Drupal and Nginx:
https://conocimientoplus.wordpress.com/2014/12/17/installing-drupal-8-on-ubuntu-14-04-with-nginx/

Ideally I would like to setup access to Trac like this: "www.drupal-blog.com/trac-project" the problem is I am not understanding what I need to do in order to make have nginx serve the trac site for me... I don't fully understand what is goin on at this point and this issue im having my be easy to fix.

Would someone please help guide me, step by step as to what to do to get this working?


Thank you!

/david

Jun Omae

unread,
Dec 30, 2015, 10:54:03 PM12/30/15
to trac-...@googlegroups.com
On Thursday, 31 December 2015, David Philipe Gil <davi...@gmail.com> wrote:
Would someone please help guide me, step by step as to what to do to get this working?



--
Jun Omae <jun...@gmail.com> (大前 潤)

David Philipe Gil

unread,
Dec 31, 2015, 7:19:06 AM12/31/15
to trac-...@googlegroups.com

Of course I have looked at that. I find the information unclear. Can you help further?

/david

--
You received this message because you are subscribed to a topic in the Google Groups "Trac Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/trac-users/xvJTR9ta57I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to trac-users+...@googlegroups.com.
To post to this group, send email to trac-...@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.

Cooke, Mark

unread,
Dec 31, 2015, 7:48:25 AM12/31/15
to trac-...@googlegroups.com
> -----Original Message-----
> From: trac-...@googlegroups.com On Behalf Of David Philipe Gil
> Sent: 31 December 2015 12:19
>
> Of course I have looked at that. I find the information unclear. Can you help
> further?
>
> /david

Whatever your intention I find your response somewhat curt, bordering on rude.

There is a very good post somewhere about how to ask good questions of people who are, after all, spending their own free time to help you. Perhaps you could find that (hint: "How To Ask Questions The Smart Way") before posting again with more detail about what exactly you are having trouble with. What do you find unclear? What have you already tried? What worked and what not?

When you do get it working, please use your notes to update the article Jun linked to [1] to help those who come after you.

[1] http://trac.edgewall.org/wiki/TracNginxRecipe

~ Mark C

P.S. I cannot help you further as I use apache httpd on windows.

David Philipe Gil

unread,
Dec 31, 2015, 8:22:30 AM12/31/15
to trac-...@googlegroups.com
Mark, im sorry if I was a bit curt. I was responding via phone with a tiny keyboard. Not my intention at all.

I have already looked at the official TracNginxRecipe. I don't understand it. I am new to Nginx, Trac running my own web server, etc.

Please let me clarify some of what I find unclear...

"

Single-Site tracd Startup: will not work with Trac before version 0.10:

tracd -d -p 3050 --pidfile=/var/live/run/tracd.3051 --protocol=http -s /var/live/trac/telecardia

"

what is a pidfile? and do I need to create that folder that has tracd.3051?


Also where it has the Sample /etc/nginx/nginx.conf is, I dont udnerstand why you would add it to the nginx.conf file. Wouldnt this go to the sites-available/ sites-enabled/ folder?

I think my question is, where do I need to edit in order to see the trac project page through nginx?

Again I am really, really appreciative of the help if any, anyone could provide. I have spent days trying to figure this out and I am basically stuck.

Having a quick look at the tutorials I said I have done, I believe would help someone see where im at with my setup. I have basically been following those tutorials.


Thanks for any help you could provide.


/david


Paul Mackinney

unread,
Dec 31, 2015, 2:02:43 PM12/31/15
to trac-...@googlegroups.com
David,

To answer your specific questions:

A pid file is a process id file. Linux daemons use them to answer questions such as "am I already running, and if so, what is my process id?"

The nginx.conf file is used to configure nginx. The files in sites-available/ are used to configure websites hosted by nginx. The files in sites-enabled/ are symlinks to the files in sites-available/. The take-away is that nginx.conf is where you'll configure nginx, and sites-available/your_trac_instance.conf is where you'll configure the interface between nginx and trac.

To answer your original question: 

I doubt that anyone here will provide you with a custom step-by-step recipe. I get paid for that level of service. You probably can get help if you ask a questions about a specific step in the tutorial, explaining what you've tried and what errors you get.

Regards, PM

--
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+...@googlegroups.com.

To post to this group, send email to trac-...@googlegroups.com.
Visit this group at https://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/d/optout.



--
Paul Mackinney
Systems & Quality Manager
O.N. Diagnostics, LLC
2150 Shattuck Ave. Suite 610, Berkeley, CA 94704
510-204-0688 (phone) | 510-356-4349 (fax)
_____________________________________________
If you receive this message in error, please delete it immediately. This message may contain information that is privileged, confidential and exempt from disclosure and dissemination under applicable law.

David Philipe Gil

unread,
Jan 1, 2016, 11:20:37 AM1/1/16
to trac-...@googlegroups.com
Thanks Paul. its been an interesting ride. Tutorials can teach you to do stuff you don't understand and eventually there comes a point where you have to understand each part. I guess I was getting overwhelmed by the huge amoutn of things I don't know piling up.

Seems to me the TracNginxRecipe page could use some love. Once I figure stuff out, I'll suggest tweaks to that page. I know there are probably lots of people who want and need this.

/david

RjOllos

unread,
Jan 22, 2016, 12:42:45 AM1/22/16
to Trac Users


On Friday, January 1, 2016 at 8:20:37 AM UTC-8, David Philipe Gil wrote:
Thanks Paul. its been an interesting ride. Tutorials can teach you to do stuff you don't understand and eventually there comes a point where you have to understand each part. I guess I was getting overwhelmed by the huge amoutn of things I don't know piling up.

Seems to me the TracNginxRecipe page could use some love. Once I figure stuff out, I'll suggest tweaks to that page. I know there are probably lots of people who want and need this.

/david 

Questions about Nginx seem to be coming up more often these days. I agree that Trac documentation isn't as good for Nginx as for Apache with mod-wsgi or mod-python. For that matter, the Apache pages need a refresh as well.

If we could eventually assemble a solid page describing how to setup Nginx it could be moved into the pages that are distributed with Trac.

- Ryan 

Mo

unread,
Feb 1, 2016, 7:24:29 AM2/1/16
to Trac Users
Am Freitag, 22. Januar 2016 06:42:45 UTC+1 schrieb RjOllos:

If we could eventually assemble a solid page describing how to setup Nginx it could be moved into the pages that are distributed with Trac.

I definitely agree with that. At the beginning when I was installing Trac with Nginx I was trying hard to get more information. While I still have some uncertainties and questions regarding how to serve static content faster (as I'm no Nginx expert) I would like to share my working setup here with Nginx+uWSGI+Trac which in my opinion is a fast and modern combination for serving Python. I would like to see an official Nginx-Guide on our install wikis soon...

Setup for 2 trac instances (pro and test) with SSL and plain http access:

/etc/nginx/nginx.conf
user nginx nginx;
worker_processes
auto;

error_log syslog
:server=unix:/dev/log error;

events
{
    worker_connections
1024;
   
use epoll;
}

http
{
    include
/etc/nginx/mime.types;
    default_type application
/octet-stream;

    log_format main
       
'$remote_addr - $remote_user [$time_local] '
       
'"$request" $status $bytes_sent '
       
'"$http_referer" "$http_user_agent" '
       
'"$gzip_ratio"';

    client_header_timeout
10m;
    client_body_timeout
10m;
    send_timeout
10m;

    connection_pool_size
256;
    client_header_buffer_size
1k;
    large_client_header_buffers
4 2k;
    request_pool_size
4k;

    gzip on
;
    gzip_min_length
1100;
    gzip_buffers
4 8k;
    gzip_types text
/plain;

    output_buffers
1 32k;
    postpone_output
1460;

    sendfile on
;
    tcp_nopush on
;
    tcp_nodelay on
;

    keepalive_timeout
75 20;

    ignore_invalid_headers on
;

    server
{
        listen          
80;
        server_name     project
;
       
# Rewrite to force SSL:
       
#location / {
       
#    rewrite         ^/(.*)$ https://project/$1 redirect;
       
#}
        location
/ {
            root
/mnt/data/trac/start;
       
}
        location
/trac-pro {
            include uwsgi_params
;
            uwsgi_pass unix
:/run/uwsgi/trac-pro.sock;
            uwsgi_param SCRIPT_NAME
/trac-pro;
            uwsgi_modifier1
30;
       
}
        location
/trac-test {
            include uwsgi_params
;
            uwsgi_pass unix
:/run/uwsgi/trac-test.sock;
            uwsgi_param SCRIPT_NAME
/trac-test;
            uwsgi_modifier1
30;
       
}
   
}
    server
{
        listen              
443;
        server_name         project
;
        root                
/mnt/data/trac;
        ssl                  on
;
        ssl_certificate      
/etc/ssl/nginx/nginx.crt;
        ssl_certificate_key  
/etc/ssl/nginx/nginx.key;
        ssl_protocols
TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on
;
        ssl_ciphers ECDHE
-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:ECDHE-RSA-RC4-SHA:ECDHE-ECDSA-RC4-SHA:AES128:AES256:RC4-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!3DES:!MD5:!PSK;
        ssl_dhparam
/etc/ssl/nginx/nginx.dh4096.pem;
        keepalive_timeout    
70;
        add_header          
Front-End-Https    on;
        location
/ {
            root
/mnt/data/trac/start;
       
}
        location
/trac-pro {
            include uwsgi_params
;
            uwsgi_pass unix
:/run/uwsgi/trac-pro.sock;
            uwsgi_param SCRIPT_NAME
/trac-pro;
            uwsgi_modifier1
30;
       
}
        location
/trac-test {
            include uwsgi_params
;
            uwsgi_pass unix
:/run/uwsgi/trac-test.sock;
            uwsgi_param SCRIPT_NAME
/trac-test;
            uwsgi_modifier1
30;
       
}

       
# different approaches for serving static content by nginx directly:
       
#location ~ /(.*?)/chrome/site/ {
       
#    rewrite /(.*?)/chrome/site/(.*) /$1/htdocs/$2 break;
       
#    root    /mnt/data/trac/projects;
       
#}
       
#location ~ /(.*?)/chrome/common/ {
       
#    rewrite /(.*?)/chrome/common/(.*) /$1/htdocs/$2 break;
       
#    root    /mnt/data/trac/projects;
       
#}

       
#location /mnt/data/trac/projects/trac-pro/htdocs {
       
#    internal;
       
#    alias /mnt/data/trac/projects/trac-pro/htdocs;
       
#}
       
#location /mnt/data/trac/projects/trac-pro/files {
       
#    internal;
       
#    alias /mnt/data/trac/projects/trac-pro/files;
       
#}


       
#location /*/chrome/common {
       
#    alias /usr/lib64/python2.7/site-packages/trac/htdocs;
       
#}
       
#location ~ /(?<project>.+)/chrome/site {
       
#    alias /mnt/data/trac/projects/$project/htdocs/;
       
#}
       
#ocation /trac/files {
       
#   alias /mnt/data/trac/project/files;
       
#
       
#ocation /trac/trac-test/login {
       
#   auth_basic_user_file /mnt/data/trac/projects/trac-test/trac.htpasswd;
       
#   auth_basic "Login for trac-test";
       
#
   
}
}



/etc/uwsgi.d/trac-pro.ini
[uwsgi]
plugins
= python27
chown
-socket = trac:nginx
uid
= trac
gid
= trac
workers
= 6
socket
= /run/uwsgi/%n.sock

env
= TRAC_ENV=/mnt/data/trac/projects/trac-pro
env
= PYTHON_EGG_CACHE=/mnt/data/trac/.python-eggs
module = trac.web.main
callable
= dispatch_request


Reply all
Reply to author
Forward
0 new messages