No activity today, make something!
tiddlyweb Using nginx and uwsgi

20160313160649 cdent  

These instructions come from conversation in a google group thread.

I found a documentation page for how to deploy Flask applications with nginx and uwsgi to be very useful for pointers. This is because TiddlyWeb and Flask expose themselves as straightforward WSGI applications.

See also WorkingNginxConfig and WorkingUwsgiConfig for a more complex but scalable setup.

!! Install nginx.

On my Mac this was as easy as {{{brew install nginx}}}. Similar {{{apt-get}}} and {{{yum}}} commands ought to do the trick on Debian or Fedora based systems.

!! Install uWSGI.

There's uwsgi the protocol, and uwsgi the daemon. nginx supports the protocol, but needs the daemon. The easiest way to install it is with pip:

{{{ pip install uwsgi }}}

!! Create or visit your TiddlyWeb instance:

{{{ twinstance cow cd cow }}}

!! Copy in wsgiapp.py

Copy wsgiapp.py from the tiddlyweb distribution. {{{ cp /wsgiapp.py . }}}

!! Start uwsgi daemon

{{{ uwsgi -s /tmp/uwsgi.sock -w wsgiapp:application }}}

!! Change permissions on the socket

nginx's worker runs as {{{nobody}}} by default and needs to read and write the uwsgi.sock file

{{{ sudo chown nobody /tmp/uwsgi.sock }}}

!! Configure nginx.conf

Assuming you want tiddlyweb listening on {{{/}}} find the entry for {{{location /}}} in the {{{http}}} section. Comment that out and add:

{{{ location / { try_files $uri @yourapplication; } location @yourapplication { include uwsgi_params; uwsgi_pass unix:/tmp/uwsgi.sock; } }}}

If you want to use some other location you must make sure to add server_prefix to tiddlywebconfig.py.

!! Start or restart nginx

!! Visit the / URL

In my {{{nginx.conf}}} it defaults to listening on port {{{8080}}} in the distributed config. So if I go to

{{{ http://0.0.0.0:8080/ }}}

I get the root page of TiddlyWeb.