Nginx for django app and pelican website?

November 19, 2017 153 views
Nginx Django PostgreSQL Ubuntu 16.04

Following this great tutorial I was able to configure my website to run the django app I'm developing.
Now what I'd like to do would be to set up NGINX and gunicorn to run my server like this:

www.mydomain.com -> static webpage (pelican, bootstrap)
www.mydomain.com/pmapp -> Django app I'm developing

I did try this with no luck.

Any help, idea?

thanks a lot

2 comments
  • Post your final nginx config here please.

  • I created two server blocks in NGINX, one for my static website:

    server {
    
    
            listen 80;
    
    
            listen [::]:80;
    
    
    
    
    
            root /var/www/html/officinecartografiche.it;
    
    
            index index.html index.htm index.nginx-debian.html;
    
    
    
    
    
            server_name www.officinecartografiche.it, officinecartografiche.it, 207.154.206.172;
    
    
    
    
    
            location / {
    
    
                    try_files $uri $uri/ =404;
    
           }
    
    }
    
    

    and one for my django app:

    server {
    
    
        listen 80;
    
    
        listen [::]:80;
    
    
        server_name www.officinecartografiche.it, officinecartografiche.it, 207.154.206.172;
    
    
        location = /favicon.ico { access_log off; log_not_found off; }
    
    
        location /static/ {
    
    
            root /home/geouser/pmapp;
    
    
        }
    
    
    
    
    
        location /pmapp {
    
    
            #include proxy_params;
    
    
            proxy_pass http://unix:/home/geouser/pmapp/pmapp.sock;
    
    
            proxy_redirect http://www.officinecartografiche.it:8000/pmapp/ http://$host/pmapp/;
    
    
            proxy_set_header SCRIPT_NAME /pmapp;
    
    
        }
    
    }
    

    and added this to settings.py:

    FORCE_SCRIPT_NAME = '/pmapp'
    
1 Answer
Have another answer? Share your knowledge.