Lacking nginx deployment guide

564 views
Skip to first unread message

minux

unread,
Mar 9, 2011, 6:09:40 PM3/9/11
to web2py-users
Hi folks,

As a newbie to the fabulous framework, I am a bit put off when I
reached to the end of the web2py chapter about deployment and (as it
happened to me with Django before) I saw no receipt to deploy on
nginx, which is my favorite web server.

I searched around but could not find any complete tutorial, while
there are few scattered blog notes here and there.

As I am going to deploy on a tiny VPS, I am reluctant to use apache
recepit (to save memory). Also lighthttpd, does not seem to be the
best candidate, as it is discontinued and (apparently) memory
leaking.

So I left with Cherokee. However I did not like the idea of a GUI
config interface, I tried the official book's receipt as the last
resort. For some reason, I ended up with a " nohup: ignoring input and
appending output to `nohup.out'".

Cutting the long story short, I really appreciate it if someone could
point me to a complete guide for nginx deployment, or writhe one :)

cheers

Michele Alzetta

unread,
Mar 10, 2011, 7:23:45 AM3/10/11
to web...@googlegroups.com


On Thu, Mar 10, 2011 at 12:09 AM, minux <esi...@gmail.com> wrote:

Cutting the long story short, I really appreciate it if someone could
point me to a complete guide for nginx deployment, or writhe one :)

I have web2py on a linode.com VPS deployed on nginx with ssl access so I can have access to administrative interface.

As linux distro I use gentoo. Nginx and spawn-fcgi I emerge, whereas web2py I just download and install by hand.

nginx.conf contains:         

server {                                                                                                                                                                                              
        
listen       443;                                                                           
        
ssl                  on;                                                                    
        
ssl_certificate      /etc/ssl/nginx/nginx.pem;                                              
        
ssl_certificate_key  /etc/ssl/nginx/nginx.key;                                              
        
keepalive_timeout    70;                                                                    
        
server_name  my.server.name;                                                             
        
access_log  /var/log/nginx/web2py.access.log;                                               
        
location / {                                                                                
        
set $fixed_destination $http_destination;                                                   
        if (
$http_destination ~* ^https(.*)$)                                                       
        {                                                                                           
        
set $fixed_destination http$1;                                                              
        }                                                                                           
        
proxy_pass http://127.0.0.1:8000;                                                           
        
proxy_set_header Host $host;                                                               
        
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;                                              
        
proxy_set_header        Destination     $fixed_destination;                                 
        }                                                                                          
  
Is this enough for you? If people really feel it is useful I could write a guide for nginx deployment, but give me some time!   :)


pbreit

unread,
Mar 10, 2011, 11:17:13 AM3/10/11
to web...@googlegroups.com
Probably good to have nginx instructions since that seems to be the fashionabl web server right now. I'm a bit annoyed by Cherokee's lack of reliable file-based configuration as well as it's lame new marketplace.

pbreit

unread,
Mar 10, 2011, 11:17:55 AM3/10/11
to web...@googlegroups.com
Probably good to have nginx instructions since that seems to be the fashionabl web server right now. I'm a bit annoyed by Cherokee's lack of reliable file-based configuration as well as it's lame new marketplace.

However, don't you have to run nginx behind apache or another server?

Norbert Klamann

unread,
Mar 10, 2011, 12:48:44 PM3/10/11
to web...@googlegroups.com

However, don't you have to run nginx behind apache or another server?
No, ngingx is a fine fromtend

pbreit

unread,
Mar 10, 2011, 1:31:26 PM3/10/11
to web...@googlegroups.com
OK, good to know. I think I might try it out. If so, I'll publish my fabfile.

minux

unread,
Mar 10, 2011, 3:23:58 PM3/10/11
to web2py-users
I have used nginx + fcgi for php (before moving to php5-fmp, which is
more robust), however, I really lack technical talent to implement the
same for web2py, given the nginx.conf that you kindly shared. So I
would be grateful if you write up a complete guide, when you have
time.

Cheers


I would love to see the complete

On Mar 10, 12:23 pm, Michele Alzetta <michele.alze...@gmail.com>
wrote:
> On Thu, Mar 10, 2011 at 12:09 AM, minux <esip...@gmail.com> wrote:
>
> > Cutting the long story short, I really appreciate it if someone could
> > point me to a complete guide for nginx deployment, or writhe one :)
>
> I have web2py on a linode.com VPS deployed on nginx with ssl access so I can
> have access to administrative interface.
>
> As linux distro I use gentoo. Nginx and spawn-fcgi I emerge, whereas web2py
> I just download and install by hand.
>
> nginx.conf contains:
>
> server {
>         listen       443;
>         ssl                  on;
>         ssl_certificate      /etc/ssl/nginx/nginx.pem;
>         ssl_certificate_key  /etc/ssl/nginx/nginx.key;
>         keepalive_timeout    70;
>         server_name  my.server.name;
>         access_log  /var/log/nginx/web2py.access.log;
>         location / {
>         set $fixed_destination $http_destination;
>         if ($http_destination ~* ^https(.*)$)
>         {
>         set $fixed_destination http$1;
>         }
>         proxy_passhttp://127.0.0.1:8000;

minux

unread,
Mar 10, 2011, 3:48:11 PM3/10/11
to web2py-users
pbreit, thanks your concise guide

http://web2pyslices.com/main/slices/take_slice/110

I could set up cherokee+uwsgi.
However, I don't like Windowish attitude that treats users as dumbs
(like, "this settings are not meant to be changed by you"...etc) and
commercialized self-promoting approach of cherokee.

So I would love to see a nginx+uwsgi guide like yours for cherokee. As
this benchmarks shows:

http://nichol.as/benchmark-of-python-web-servers

uwsgi is among the best (if not the best) option to be used for a
python web framework. So if you want to write a guide, I guess it
would be better to implement uwsgi, rather than fcgi.

Vasile Ermicioi

unread,
Mar 11, 2011, 2:42:48 AM3/11/11
to web...@googlegroups.com
yes, a guide for nginx + uwsgi will be great

pbreit

unread,
Mar 11, 2011, 12:39:50 PM3/11/11
to web...@googlegroups.com
I finally got it working but it was a mess.

These steps wil get it done. Linode is really the best resource for setting up on Ubuntu. There is a lot of out-dated, confusing or mis-information out there. Start with the Ubuntu docs and Linode Library.


The one thing you have to do is NOT set up and use the "uwsgi" user. Instead, make sure the user is "www-data". So wherever you see "chown uwsgi", use "chown www-data" instead. And, in the uwsgi init.d file that you grab from Linode, edit the "user" to "www-data".

For the wsgi file, put this in. I'm pretty sure this file is necessary although it seemed like there were different ways to config this.
PYTHONPATH=/var/web2py  #your path to web2py
MODULE=wsgihandler
This is the nginx.conf I used. No ssl yet. I will submit my fabfile when I confirm it. ANd I'd like to get SSL working.

user www-data;
worker_processes  4;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    keepalive_timeout  2;
    sendfile        on;
    #tcp_nopush     on;
    tcp_nodelay     on;
    gzip  on;
    server {
        listen       80;
        server_name  "";

        location / {
            uwsgi_pass 127.0.0.1:9001;
            include uwsgi_params;
        }
        
        location /static {
            root /var/web2py/applications/init/;
        }
    }   

}

pbreit

unread,
Mar 12, 2011, 2:27:41 AM3/12/11
to web...@googlegroups.com
OK, here's my fab def() and nginx.conf (configured for one static directory in app "init"). You can either reproduce the steps manually as listed in the fabfile or put it in your fabfile (much easier!). If you're not familiar with Fabric, most commands are preceded with a "cd" command because each command is discrete and you cannot rely on staying in the same directory.

Credit: http://library.linode.com/web-servers/nginx/python-uwsgi/ubuntu-10.04-lucid

The two init.d files are:

=== fabfile.py ===
def setup_nginx():
    sudo('apt-get -y install build-essential psmisc python-dev libxml2 libxml2-dev python-setuptools')
    sudo('cd /opt; tar -zxvf uwsgi*')
    sudo('mv /opt/uwsgi*/ /opt/uwsgi/')
    sudo('cd /opt/uwsgi/; python setup.py install')
    sudo('chown -R www-data:www-data /opt/uwsgi')
    sudo('touch /var/log/uwsgi.log')
    sudo('chown www-data /var/log/uwsgi.log')
    sudo('apt-get -y install libpcre3-dev build-essential libssl-dev')
    sudo('cd /opt; tar -zxvf nginx*')
    sudo('cd /opt/nginx*/; ./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module')
    sudo('cd /opt/nginx*/; make')
    sudo('cd /opt/nginx*/; make install')
    sudo('adduser --system --no-create-home --disabled-login --disabled-password --group nginx')
    sudo('cp /opt/uwsgi*/nginx/uwsgi_params /opt/nginx/conf/uwsgi_params')
    put('init-nginx', '/etc/init.d/nginx')
    sudo('chmod +x /etc/init.d/nginx')
    sudo('/usr/sbin/update-rc.d -f nginx defaults')
    sudo('/etc/init.d/nginx start')  
    put('init-uwsgi', '/etc/init.d/uwsgi')
    sudo('chmod +x /etc/init.d/uwsgi')
    sudo("""echo 'PYTHONPATH=/var/web2py/
MODULE=wsgihandler' >> /etc/default/uwsgi""")
    sudo('/usr/sbin/update-rc.d -f uwsgi defaults')
    sudo('/etc/init.d/uwsgi start')
    sudo('rm /opt/nginx/conf/nginx.conf')
    put('nginx.conf', '/opt/nginx/conf/nginx.conf')
    sudo('cd /opt/nginx/conf; openssl genrsa -out server.key 1024')
    sudo('cd /opt/nginx/conf; openssl req -batch -new -key server.key -out server.csr')
    sudo('cd /opt/nginx/conf; openssl x509 -req -days 1780 -in server.csr -signkey server.key -out server.crt')
    sudo('/etc/init.d/nginx restart')

=== nginx.conf ===
user www-data;
worker_processes  4;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    keepalive_timeout  2;
    sendfile        on;
    #tcp_nopush     on;
    tcp_nodelay     on;
    gzip  on;
    
    # HTTP server
    server {
        listen       80;
        server_name  "";

        location / {
            uwsgi_pass 127.0.0.1:9001;
            include uwsgi_params;
        }
        
        location /static {
            root /var/web2py/applications/init/;
        }
    }
    
    # HTTPS server
    server {
        listen       443;
        server_name  "";
        ssl                  on;
        ssl_certificate      /opt/nginx/conf/server.crt;
        ssl_certificate_key  /opt/nginx/conf/server.key;

pbreit

unread,
Mar 13, 2011, 4:46:50 AM3/13/11
to web...@googlegroups.com
It seems like nginx can be run by www-data as well. So:

Delete:
sudo('adduser --system --no-create-home --disabled-login --disabled-password --group nginx')

Edit:
sudo('cd /opt/nginx*/; ./configure --prefix=/opt/nginx --user=www-data --group=www-data --with-http_ssl_module')

If anyone has an tips, suggestions or corrections, please let me know. I am relatively new to all of this.

Michele Alzetta

unread,
Mar 13, 2011, 5:11:48 PM3/13/11
to web...@googlegroups.com

If anyone has an tips, suggestions or corrections, please let me know. I am relatively new to all of this.

Looks great. I'm almost tempted to try it myself ... but as at the moment my web2py is under no serious load I'll probably follow the "if it works, don't break it" philosophy :)


pbreit

unread,
Mar 13, 2011, 6:42:56 PM3/13/11
to web...@googlegroups.com
I'm having an issue that is affecting my ability to access admin. If you look at the attached, you can see that even though I am accessing an HTTPS url, the wsgi.url_scheme value is reporting HTTP. I'm not sure what the problem is. I've seen some information about including settings in nginx.conf to set certain parameters but have so far been unable to make anything work. I edited my appadmin/admin to accept a connection through "http":
if request.env.http_x_forwarded_for or request.env.wsgi_url_scheme in ['https', 'HTTPS', 'http']:  #added 'http'

It could be an issue of getting the information to uwsgi and then to web2py. Hard to say for this newbie.
Screen shot 2011-03-13 at 3.37.28 PM.png

pbreit

unread,
Mar 13, 2011, 7:45:25 PM3/13/11
to web...@googlegroups.com
I think I figured out the solution. Need to add one line to the nginx.conf:
uwsgi_param     UWSGI_SCHEME    $scheme;


    # HTTPS server
    server {
        listen       443;
        server_name  "";
        ssl                  on;
        ssl_certificate      /opt/nginx/conf/server.crt;
        ssl_certificate_key  /opt/nginx/conf/server.key;

        location / {
            uwsgi_pass      127.0.0.1:9001;
            include         uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
        }
           
        location /static {
            root /var/web2py/applications/init/;
        }
    }

minux

unread,
Mar 17, 2011, 1:00:50 AM3/17/11
to web2py-users
pbreit, I tried to follow the Linode recipe along with your
instructions, but could not succeed. There were points were I really
did not know what changes are needed to be made.
For example:
in '/etc/init.d/uwsgi' should the owner be uwsgi or www-data?
in /etc/default/uwsgi, should the 'MODULE=wsgi_configuration_module'
be included? If so, with what changes...
etc.

So I really appreciate it if you or others from web2py community can
sum up a complete recipe for deployment using nginx+uwsgi.

Cheers




file and so I appre

minux

unread,
Mar 17, 2011, 6:25:00 AM3/17/11
to web2py-users
pbreit, please ignore my last post. Actually I could make nginx+uwsgi
up and running by reading carefully your posts above. I have sum up
the instructions here:

http://stackoverflow.com/questions/5335153/how-to-deply-web2py-using-nginx

Thank you so much for your help.



VP

unread,
Mar 26, 2011, 1:41:13 PM3/26/11
to web2py-users
I followed the steps here but got a 502 Bad Gateway error from nginx.


On Mar 17, 5:25 am, minux <esip...@gmail.com> wrote:
> pbreit, please ignore my last post. Actually I could make nginx+uwsgi
> up and running by reading carefully your posts above. I have sum up
> the instructions here:
>
> http://stackoverflow.com/questions/5335153/how-to-deply-web2py-using-...

pbreit

unread,
Mar 26, 2011, 2:05:49 PM3/26/11
to web...@googlegroups.com
Ok, let me double check the steps. I think that's an issue with nginx finding uWSGI or uWSGI finding web2py. You might dig through the nginx or uWSGI logs. Are your static files getting served ok? Is it a clean install of 10.04 or did the server already exist?

Vasile Ermicioi

unread,
Mar 26, 2011, 2:22:42 PM3/26/11
to web...@googlegroups.com
What about my solution ?

VP

unread,
Mar 26, 2011, 2:27:46 PM3/26/11
to web2py-users
I tried minux's solution above.

By the way, I have Debian squeeze and I run web2py as my own user (not
as www-data). It seems I couldn't get uwsgi to start.

VP

unread,
Mar 26, 2011, 3:19:37 PM3/26/11
to web2py-users

>>         location /static {
>>             root /var/web2py/applications/init/;
>>         }

Slowly, i'm getting it to work. Current problem: can't serve static
files (e.g. style css files). Is this configuration above correct?
I tried to point to my app static folder and didn't work either.

Dale DeWitt

unread,
Mar 26, 2011, 3:28:29 PM3/26/11
to web2py-users
There's a checkbox to turn the marketplace off. "Receive insight from
the actual people who conceived Cherokee and are the core committers
of such technology." From Enterprise Support Services, Octality I
imagine the ideas and money go both ways. Guessing of course.

LightOfMooN

unread,
Mar 26, 2011, 6:04:47 PM3/26/11
to web2py-users
Hi
I follow this guide http://stackoverflow.com/questions/5335153/how-to-deply-web2py-using-nginx
I have ubuntu 10.4 + nginx + web2py, installed in var

And the result is 502 Bad Gateway.
Any suggestions?

VP

unread,
Mar 26, 2011, 7:55:30 PM3/26/11
to web2py-users
Make sure uwsgi has the correct path. Look at /etc/init.d/uswgi

There's a path to uwsgi. The latest uwsgi sets the path to /usr/bin/
uwgsi but it might have been installed in /usr/local/bin/uwsgi



On Mar 26, 5:04 pm, LightOfMooN <vladsale...@yandex.ru> wrote:
> Hi
> I follow this guidehttp://stackoverflow.com/questions/5335153/how-to-deply-web2py-using-...

David J.

unread,
Mar 26, 2011, 10:32:00 PM3/26/11
to web...@googlegroups.com
I don't know about running web2py using uwsgi;

However;

When I run web2py with nginx I use the fastcgi module;

I configure nginx like described in the stackoverflow article;

except I use fastcgi;

In nginx config I have

location / {
include fascgi_params;
fastcgi_pass unix:/tmp/fcgi.sock

}

then go to web2py root and run the python fastcgihandler.py script;

The caveat is that you have to change the permissions on the
/tmp/fcgi.sock file because when web2py runs it; its run under the user
that started the process;

so you do

chown nginx:nginx /tmp/fcgi.sock

and then your done;

You wont get and 502 errors or anything; its really quite simple;

I am not sure if the uwsgi implementation is better as I am trying that
tonight; but fastcgi has be running very stable for the past few months.

I apologize for the lack of detailed instructions (I am not in front of
the configs) but if you have any questions I can look into it further
and try to help.

Thanks.

LightOfMooN

unread,
Mar 27, 2011, 1:44:35 AM3/27/11
to web2py-users
That is what I have in /etc/init.d/uwsgi:

PATH=/opt/uwsgi:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/uwsgi
OWNER=uwsgi

Should I modify it to:

PATH=/opt/uwsgi:/sbin:/bin:/usr/sbin:/usr/local/bin
DAEMON=/usr/local/bin/uwsgi
OWNER=www-data

?

LightOfMooN

unread,
Mar 27, 2011, 3:02:27 AM3/27/11
to web2py-users
I reinstalled Nginx with
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx

and now have error with sertificates

ssl_certificate /opt/nginx/conf/server.crt;
ssl_certificate_key /opt/nginx/conf/server.key;

Where can I get it?

On 27 мар, 05:55, VP <vtp2...@gmail.com> wrote:

LightOfMooN

unread,
Mar 27, 2011, 3:07:58 AM3/27/11
to web2py-users
David, I'd like to try nginx with fastcgi.
Can you give me some helpful links to deploy it?
> > I follow this guidehttp://stackoverflow.com/questions/5335153/how-to-deply-web2py-using-...

pbreit

unread,
Mar 27, 2011, 3:24:01 AM3/27/11
to web...@googlegroups.com
OK, here's another try. This is just a shell script which I have verified works on a clean Ubuntu 10.04 install. This script needs no additional editing. To get it to work with the script provided by Linode, everything is owned be the user "uwsgi". Besides the script, the only other place where the user is specified is in the uwsgi init.d script. Still working on SSL but that shouldn't be too hard. Sorry if I have wasted anyone's time. I have certainly wasted a lot of my own!

SSH in as root:
root$ vi setup.sh (paste the script below and save)
root$ chmod +x setup.sh
root$ sudo ./setup.sh

=== setup.sh ===
#!/bin/bash

apt-get update
apt-get -y upgrade
apt-get -y install build-essential psmisc python-dev libxml2 libxml2-dev python-setuptools
adduser --system --no-create-home --disabled-login --disabled-password --group uwsgi

apt-get -y install unzip
cd /opt/
unzip web2py_src.zip
chown -R uwsgi:uwsgi web2py
cd web2py
sudo -u uwsgi python -c "from gluon.widget import console; console();"
sudo -u uwsgi python -c "from gluon.main import save_password; save_password(raw_input('admin password: '),443)"

cd /opt/
tar -zxvf uwsgi*
mv uwsgi*/ uwsgi/
cd uwsgi/
python setup.py install
chown -R uwsgi:uwsgi /opt/uwsgi
touch /var/log/uwsgi.log
chown uwsgi /var/log/uwsgi.log

apt-get -y install libpcre3-dev build-essential libssl-dev
cd /opt/
tar -zxvf nginx-0.8.54.tar.gz
cd /opt/nginx-0.8.54/
./configure --prefix=/opt/nginx --user=nginx --group=nginx --with-http_ssl_module
make
make install
adduser --system --no-create-home --disabled-login --disabled-password --group nginx
cp /opt/uwsgi/nginx/uwsgi_params /opt/nginx/conf/uwsgi_params
mv init-deb.sh /etc/init.d/nginx
chmod +x /etc/init.d/nginx
/usr/sbin/update-rc.d -f nginx defaults
/etc/init.d/nginx start
cd /opt/
mv /opt/init-deb.sh /etc/init.d/uwsgi
chmod +x /etc/init.d/uwsgi
echo 'PYTHONPATH=/opt/web2py/
MODULE=wsgihandler' > /etc/default/uwsgi
/usr/sbin/update-rc.d -f uwsgi defaults
/etc/init.d/uwsgi start

echo 'user uwsgi;
worker_processes  4;

events {
    worker_connections  1024;
}

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

    server {
        listen       80;
        server_name  "";

        location / {
            uwsgi_pass     127.0.0.1:9001;
            include        uwsgi_params;
        }
        
        location /static {
            root   /opt/web2py/applications/welcome/;
        }
    }
}' > /opt/nginx/conf/nginx.conf
/etc/init.d/nginx restart

pbreit

unread,
Mar 27, 2011, 3:47:06 AM3/27/11
to web...@googlegroups.com
Ah, that's probably what caused the problems since my scripts were pulling the latest version not a specific version.

LightOfMooN

unread,
Mar 27, 2011, 3:50:36 AM3/27/11
to web2py-users
Huh, it runs :)
Thanks a lot!
I think, this + 443 port should be on web2py slices
Thanks again

On 27 мар, 13:24, pbreit <pbreitenb...@gmail.com> wrote:
> OK, here's another try. This is just a shell script which I have verified
> works on a clean Ubuntu 10.04 install. This script needs no additional
> editing. To get it to work with the script provided by Linode, everything is
> owned be the user "uwsgi". Besides the script, the only other place where
> the user is specified is in the uwsgi init.d script. Still working on SSL
> but that shouldn't be too hard. Sorry if I have wasted anyone's time. I have
> certainly wasted a lot of my own!
>
> SSH in as root:
> root$ vi setup.sh (paste the script below and save)
> root$ chmod +x setup.sh
> root$ sudo ./setup.sh
>
> === setup.sh ===
> #!/bin/bash
>
> apt-get update
> apt-get -y upgrade
> apt-get -y install build-essential psmisc python-dev libxml2 libxml2-dev
> python-setuptools
> adduser --system --no-create-home --disabled-login --disabled-password
> --group uwsgi
>
> apt-get -y install unzip
> cd /opt/
> wgethttp://web2py.com/examples/static/web2py_src.zip
> unzip web2py_src.zip
> chown -R uwsgi:uwsgi web2py
> cd web2py
> sudo -u uwsgi python -c "from gluon.widget import console; console();"
> sudo -u uwsgi python -c "from gluon.main import save_password;
> save_password(raw_input('admin password: '),443)"
>
> cd /opt/
> wgethttp://projects.unbit.it/downloads/uwsgi-0.9.6.8.tar.gz
> tar -zxvf uwsgi*
> mv uwsgi*/ uwsgi/
> cd uwsgi/
> python setup.py install
> chown -R uwsgi:uwsgi /opt/uwsgi
> touch /var/log/uwsgi.log
> chown uwsgi /var/log/uwsgi.log
>
> apt-get -y install libpcre3-dev build-essential libssl-dev
> cd /opt/
> wgethttp://nginx.org/download/nginx-0.8.54.tar.gz
> tar -zxvf nginx-0.8.54.tar.gz
> cd /opt/nginx-0.8.54/
> ./configure --prefix=/opt/nginx --user=nginx --group=nginx
> --with-http_ssl_module
> make
> make install
> adduser --system --no-create-home --disabled-login --disabled-password
> --group nginx
> cp /opt/uwsgi/nginx/uwsgi_params /opt/nginx/conf/uwsgi_params
> wgethttps://library.linode.com/web-servers/nginx/installation/reference/i...
> mv init-deb.sh /etc/init.d/nginx
> chmod +x /etc/init.d/nginx
> /usr/sbin/update-rc.d -f nginx defaults
> /etc/init.d/nginx start
> cd /opt/
> wgethttps://library.linode.com/web-servers/nginx/python-uwsgi/reference/i...

LightOfMooN

unread,
Mar 27, 2011, 4:18:13 AM3/27/11
to web2py-users
Can't configure SSL.
pbreit, can you help?

I used this to create certificate:

cd /opt/nginx/conf; openssl genrsa -out server.key 1024
cd /opt/nginx/conf; openssl req -batch -new -key server.key -out
server.csr
cd /opt/nginx/conf;
openssl x509 -req -days 1780 -in server.csr -signkey server.key -out
server.crt

And add this to nginx.conf

server {
listen 443;
server_name "";
ssl on;
ssl_certificate /opt/nginx/conf/server.crt;
ssl_certificate_key /opt/nginx/conf/server.key;

location / {
uwsgi_pass 127.0.0.1:9001;
include uwsgi_params;
uwsgi_param UWSGI_SCHEME $scheme;
}
location /static {
root /opt/web2py/applications/welcome/;
}
}

But if I try to start nginx, it rises error:
unknown directive "ssl"

LightOfMooN

unread,
Mar 27, 2011, 4:36:28 AM3/27/11
to web2py-users
Sorry, it's my bad. Just compiled without http_ssl_module, because I
missed newline when pasted script

LightOfMooN

unread,
Mar 27, 2011, 5:33:11 AM3/27/11
to web2py-users
also need add into nginx.conf something like this:

sendfile on;
client_max_body_size 100M;

to avoid 413 Request Entity Too Large
when upload big files

pbreit

unread,
Jun 14, 2011, 6:51:20 PM6/14/11
to web...@googlegroups.com
That looks right. This is what I have. Are you getting an error or the wrong file? Might need to look in your nginx access.log to see what it's trying to serve. Maybe there's a conflict with routes.py?

    server {
        server_name _;

        location / {
            uwsgi_pass 127.0.0.1:9001;
            include uwsgi_params;
            uwsgi_param     UWSGI_SCHEME $scheme;
        }

        location /static {
            root /var/web2py/applications/init/;
        }
    }
Reply all
Reply to author
Forward
0 new messages