Report this

What is the reason for this report?

Deploying Pyramid app: Nginx + Pserve

Posted on April 21, 2014

I’ve been following this recipe in the Pyramid Cookbook (http://pyramid-cookbook.readthedocs.org/en/latest/deployment/nginx.html) to try and deploy my app on DigitalOcean. It seems to work, I get the message Entering daemon mode just like I did when running on my local machine.

I’ve also added my domain name and set up my nameservers to point to DigitalOcean.

When I try to access my site at wisderm.com though, it doesn’t load. I’m completely lost at this point – What am I doing wrong?

This is how my files are structured:

home/
  |----env/ # virtualenv
  |----MyApp/
        |
        |----production.ini
        |----requirements.txt
        |----myapp.sql
        |----myapp.psql
        |----MyProject
              |
              |----scripts/
              |----static/
              |----templates/
              |----__init__.py
              |----views.py
              |----models.py

This is my app.conf:

upstream myapp-site {
    server 127.0.0.1:5000;
    server 127.0.0.1:5001;
}

server {

    server_name  wisderm.com;

    access_log  /home/myapp/access.log;

    location / {
        proxy_set_header        Host $http_host;
        proxy_set_header        X-Real-IP $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header        X-Forwarded-Proto $scheme;

        client_max_body_size    10m;
        client_body_buffer_size 128k;
        proxy_connect_timeout   60s;
        proxy_send_timeout      90s;
        proxy_read_timeout      90s;
        proxy_buffering         off;
        proxy_temp_file_write_size 64k;
        proxy_pass http://myapp-site;
        proxy_redirect          off;
    }

    location /static {
    root                    /home/MyApp;
    expires                 30d;
    add_header              Cache-Control public;
    access_log              off;
  }
}


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

There doesn’t seem to be anything listening on port 80 – is nginx running? <pre>sudo netstat -plutn | grep nginx <br>sudo service nginx start</pre>

Yes, I forgot to deploy it yesterday. <br> <br>This is what I get with sudo netstat -plutn | grep nginx <br>tcp 0 0.0.0.0:80 0.0.0.0:* LISTEN 24042/nginx <br> <br>Now something is loading, but its a 404 error: http://wisderm.com/

I checked out the error logs using tail /var/log/nginx/error.log, and there are plenty of these errors: <br> <br>2014/04/22 01:24:18 [error] 25568#0: *11 “/etc/nginx/html/index.html” is not found (2: No such file or directory), client: 220.255.2.78, server: wisderm.com, request: “GET / HTTP/1.1”, upstream “http://127.0.0.1:5001/”, host: “wisderm.com” <br> <br>2014/04/22 02:12:13 [error] 25792#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 220.255.2.78, server: wisderm.com, request: “GET / HTTP/1.1”, upstream “http://127.0.0.1:5001/”, host: “wisderm.com” <br> <br>Why is it trying to get to /etc/nginx/html/index.html? Clearly my knowledge of VPS and app deployment is really lacking, and I appreciate the help.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.