|  | @@ -0,0 +1,101 @@
 | 
	
		
			
			|  | 1 | +# Running Tracim through nginx #
 | 
	
		
			
			|  | 2 | +
 | 
	
		
			
			|  | 3 | +### Installation ###
 | 
	
		
			
			|  | 4 | +
 | 
	
		
			
			|  | 5 | +Install `nginx` http server and `uWSGI` app server:
 | 
	
		
			
			|  | 6 | +
 | 
	
		
			
			|  | 7 | +    sudo apt install nginx uwsgi uwsgi-plugin-python3
 | 
	
		
			
			|  | 8 | +
 | 
	
		
			
			|  | 9 | +### Configuration ###
 | 
	
		
			
			|  | 10 | +
 | 
	
		
			
			|  | 11 | +In the following documentation, please replace:
 | 
	
		
			
			|  | 12 | +
 | 
	
		
			
			|  | 13 | +- `[tracim_path]` by  your tracim installation path,
 | 
	
		
			
			|  | 14 | +- `[your_user]` by your user.
 | 
	
		
			
			|  | 15 | +
 | 
	
		
			
			|  | 16 | +Set the `APP_CONFIG` variable of the `tracim/app.wsgi` file to match your tracim installation path:
 | 
	
		
			
			|  | 17 | +
 | 
	
		
			
			|  | 18 | +    # -*- coding: utf-8 -*-
 | 
	
		
			
			|  | 19 | +
 | 
	
		
			
			|  | 20 | +    APP_CONFIG = "[tracim_path]/tracim/development.ini"
 | 
	
		
			
			|  | 21 | +
 | 
	
		
			
			|  | 22 | +    #Setup logging
 | 
	
		
			
			|  | 23 | +    # import logging
 | 
	
		
			
			|  | 24 | +    # logging.config.fileConfig(APP_CONFIG)
 | 
	
		
			
			|  | 25 | +
 | 
	
		
			
			|  | 26 | +    #Load the application
 | 
	
		
			
			|  | 27 | +    from paste.deploy import loadapp
 | 
	
		
			
			|  | 28 | +    application = loadapp('config:%s' % APP_CONFIG)
 | 
	
		
			
			|  | 29 | +    application.debug = False
 | 
	
		
			
			|  | 30 | +
 | 
	
		
			
			|  | 31 | +Create the file named `/etc/uwsgi/apps-available/tracim_uwsgi.ini` containing:
 | 
	
		
			
			|  | 32 | +
 | 
	
		
			
			|  | 33 | +    [uwsgi]
 | 
	
		
			
			|  | 34 | +    plugins = python3
 | 
	
		
			
			|  | 35 | +    chdir = [tracim]/tracim
 | 
	
		
			
			|  | 36 | +    home = [tracim]/tg2env
 | 
	
		
			
			|  | 37 | +    wsgi-file = app.wsgi
 | 
	
		
			
			|  | 38 | +    callable = application
 | 
	
		
			
			|  | 39 | +    # socket = /var/run/uwsgi/app/tracim/socket
 | 
	
		
			
			|  | 40 | +    socket = :8001
 | 
	
		
			
			|  | 41 | +    enable-threads = true
 | 
	
		
			
			|  | 42 | +    uid = [your_user]
 | 
	
		
			
			|  | 43 | +    gid = [your_user]
 | 
	
		
			
			|  | 44 | +
 | 
	
		
			
			|  | 45 | +Create a file named `/etc/nginx/sites-available/tracim_nginx.conf` containing:
 | 
	
		
			
			|  | 46 | +
 | 
	
		
			
			|  | 47 | +    server {
 | 
	
		
			
			|  | 48 | +        listen      8080;
 | 
	
		
			
			|  | 49 | +        server_name tracim;
 | 
	
		
			
			|  | 50 | +        charset     utf-8;
 | 
	
		
			
			|  | 51 | +
 | 
	
		
			
			|  | 52 | +        client_max_body_size 75M;
 | 
	
		
			
			|  | 53 | +
 | 
	
		
			
			|  | 54 | +        location /caldav {
 | 
	
		
			
			|  | 55 | +            proxy_pass http://127.0.0.1:10000;
 | 
	
		
			
			|  | 56 | +            proxy_set_header Host $http_host;
 | 
	
		
			
			|  | 57 | +        }
 | 
	
		
			
			|  | 58 | +
 | 
	
		
			
			|  | 59 | +        location /webdav {
 | 
	
		
			
			|  | 60 | +            proxy_pass http://127.0.0.1:3031;
 | 
	
		
			
			|  | 61 | +            proxy_set_header Host $http_host;
 | 
	
		
			
			|  | 62 | +        }
 | 
	
		
			
			|  | 63 | +
 | 
	
		
			
			|  | 64 | +        location /favicon.ico {
 | 
	
		
			
			|  | 65 | +            alias [tracim_path]/tracim/tracim/public/favicon.ico
 | 
	
		
			
			|  | 66 | +        }
 | 
	
		
			
			|  | 67 | +
 | 
	
		
			
			|  | 68 | +        location /assets {
 | 
	
		
			
			|  | 69 | +            root [tracim_path]/tracim/tracim/public/assets;
 | 
	
		
			
			|  | 70 | +            try_files $uri @default_assets;
 | 
	
		
			
			|  | 71 | +        }
 | 
	
		
			
			|  | 72 | +
 | 
	
		
			
			|  | 73 | +        location @default_assets {
 | 
	
		
			
			|  | 74 | +            root [tracim_path]/tracim/tracim/public/;
 | 
	
		
			
			|  | 75 | +        }
 | 
	
		
			
			|  | 76 | +
 | 
	
		
			
			|  | 77 | +        location / {
 | 
	
		
			
			|  | 78 | +            # uwsgi_pass  unix:/var/run/uwsgi/app/tracim/socket;
 | 
	
		
			
			|  | 79 | +            uwsgi_pass  127.0.0.1:8001;
 | 
	
		
			
			|  | 80 | +            include uwsgi_params;
 | 
	
		
			
			|  | 81 | +            uwsgi_param  SCRIPT_NAME  '';
 | 
	
		
			
			|  | 82 | +        }
 | 
	
		
			
			|  | 83 | +    }
 | 
	
		
			
			|  | 84 | +
 | 
	
		
			
			|  | 85 | +Enable this site configuration file:
 | 
	
		
			
			|  | 86 | +
 | 
	
		
			
			|  | 87 | +    sudo ln -s /etc/nginx/sites-available/tracim_nginx.conf /etc/nginx/sites-enabled/
 | 
	
		
			
			|  | 88 | +
 | 
	
		
			
			|  | 89 | +Reload `nginx` configuration:
 | 
	
		
			
			|  | 90 | +
 | 
	
		
			
			|  | 91 | +    sudo systemctl reload nginx.service
 | 
	
		
			
			|  | 92 | +
 | 
	
		
			
			|  | 93 | +Run uWSGI, by example with the following command:
 | 
	
		
			
			|  | 94 | +
 | 
	
		
			
			|  | 95 | +    uwsgi --ini /etc/uwsgi/apps-available/tracim_uwsgi.ini
 | 
	
		
			
			|  | 96 | +
 | 
	
		
			
			|  | 97 | +Tracim should be available in your browser at `127.0.0.1:8080`.
 | 
	
		
			
			|  | 98 | +
 | 
	
		
			
			|  | 99 | +## Documentation Links ##
 | 
	
		
			
			|  | 100 | +
 | 
	
		
			
			|  | 101 | +[uWSGI](http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html)
 |