NginX UWSGI and Web2py [Solved]

Don´t be shy, Linux is fun! =)
Post Reply
User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1624
Joined: 28 Aug 2005, 16:00
18

NginX UWSGI and Web2py [Solved]

Post by maboroshi »

Write now I am running nginx/uwsgi with Web2py at a very base setup. I would like to incorporate a very minimalist web admin interface. If possible I would like to write one. But I am a bit confused how to handle Web2py. Web2py handles its own domain routing via routes.py. Having experimented with other web2py hosts I think I would need to create separate instances of web2py with separate routes.py files.

So the question is: How can I create these separate running web2py instances with there own admin panels (admin needs to run on https for web2py) and routes.py and map them into uwsgi and nginx?

this is my default config for nginx and uwsgi

NGINX

Code: Select all

server {
        listen          80;
        server_name     $hostname;
        location ~* ^/(\w+)/static/ {
            root /home/www-data/web2py/applications/;
        }

	location = /robots.txt  { access_log off; log_not_found off; }
	location = /favicon.ico { access_log off; log_not_found off; }
	location ~ /\.          { access_log off; log_not_found off; deny all; }
	location ~ ~$           { access_log off; log_not_found off; deny all; }

        location / {
            uwsgi_pass      unix:///tmp/web2py.socket;
            include         uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
            uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;
        }
}
server {
        listen 443 default_server ssl;
        server_name     $hostname;
        ssl_certificate         /etc/nginx/ssl/web2py.crt;
        ssl_certificate_key     /etc/nginx/ssl/web2py.key;
        ssl_prefer_server_ciphers on;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 10m;
        ssl_ciphers ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA;
        ssl_protocols SSLv3 TLSv1;
        keepalive_timeout    70;
        location / {
            uwsgi_pass      unix:///tmp/web2py.socket;
            include         uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
            uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;
        }
}
UWSGI

Code: Select all

[uwsgi]

socket = /tmp/web2py.socket
pythonpath = /home/www-data/web2py/
mount = /=wsgihandler:application
processes = 8
master = true
harakiri = 60
reload-mercy = 8
cpu-affinity = 3
stats = /tmp/stats.socket
max-requests = 2000
limit-as = 1024
reload-on-as = 512
reload-on-rss = 192
uid = www-data
gid = www-data
cron = 0 0 -1 -1 -1 python /home/www-data/web2py/web2py.py -Q -S welcome -M -R scripts/sessions2trash.py -A -o
no-orphans = true
Any suggestions in how to this would be awesome.

Would I just recreate the default conf file changing the necessary settings?

*cheers!

User avatar
maboroshi
Dr. Mab
Dr. Mab
Posts: 1624
Joined: 28 Aug 2005, 16:00
18

Re: NginX UWSGI and Web2py [Solved]

Post by maboroshi »

I managed to get it working!

Will write a tutorial explaining the steps I took tomorrow :-). Wasn't to hard to figure out.

Post Reply