NGINX + GUNICORN

55 views
Skip to first unread message

Giovanni Silva

unread,
Sep 10, 2020, 6:01:02 AM9/10/20
to django...@googlegroups.com
Dears, 

can anyone help-me to configure a NGINX + GUNICORN to multiple projects?

for the first project everything is work fine, for the second project, I create a new .socket file and new service file.. 

The nginx and gunicorn is running, but when I try to access my site, appears the default page of nginx.. 

Any suggestions??

Best regards,

--
Giovanni Silva
(31) 9 9532-1877

Kasper Laudrup

unread,
Sep 10, 2020, 7:52:36 AM9/10/20
to django...@googlegroups.com
Hi Giovanni,

On 10/09/2020 07.59, Giovanni Silva wrote:
> Dears,
>
> can anyone help-me to configure a NGINX + GUNICORN to multiple projects?
>
> for the first project everything is work fine, for the second project, I
> create a new .socket file and new service file..
>
> The nginx and gunicorn is running, but when I try to access my site,
> appears the default page of nginx..
>
> Any suggestions??
>

You would probably have a better chance of getting some help if you
provide us with the relevant parts of your nginx configuration and a bit
more information about your setup (OS etc.).

Anyway, have you tried following this guide:

http://michal.karzynski.pl/blog/2013/10/29/serving-multiple-django-applications-with-nginx-gunicorn-supervisor/

Kind regards,

Kasper Laudrup

Amitesh Sahay

unread,
Sep 10, 2020, 7:53:26 AM9/10/20
to django...@googlegroups.com
Please make sure that gunicorn.service file has same entry of project dir path as nginx.

Regards,
Amitesh


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CABO2r9dNQd24yM%3DDD-fjy9dNjV5GigYxxwNNFjtAivs5xfsKRQ%40mail.gmail.com.

Sunday Iyanu Ajayi

unread,
Sep 10, 2020, 9:08:27 AM9/10/20
to django...@googlegroups.com
In your nginx project file in /etc/nginx/site-available/xx, did you include the ip of the server you are working on?


--

Giovanni Silva

unread,
Sep 10, 2020, 9:59:53 PM9/10/20
to django...@googlegroups.com
Hello.. 

This webpage works fine:

NGINX - FILE
server {
    listen 80;
    server_name www.ascende.com.br;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/ascende/Site;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

GUNICORN SOCKET
[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock

[Install]
WantedBy=sockets.target

GUNICORN SERVICE
[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=ascende
Group=www-data
WorkingDirectory=/home/ascende/Site
ExecStart=/home/ascende/Site/venv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/gunicorn.sock \
          SiteAscende.wsgi:application

[Install]
WantedBy=multi-user.target

This doesn't work. 

NGINX - FILE
server {
    listen 81;
    server_name www.aidacomunicacao.com.br;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/aida/Site;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/siteaida.sock;
    }
}

GUNICORN SOCKET2
[Unit]
Description=siteaida socket

[Socket]
ListenStream=/run/siteaida.sock

[Install]
WantedBy=sockets.target

GUNICORN SERVICE2
[Unit]
Description=siteaida daemon
Requires=siteaida.socket
After=network.target

[Service]
User=aida
Group=www-data
WorkingDirectory=/home/aida/Site
ExecStart=/home/aida/Site/venv/bin/gunicorn \
          --access-logfile - \
          --workers 3 \
          --bind unix:/run/siteaida.sock \
          SitaAIDA.wsgi:application

[Install]
WantedBy=multi-user.target


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Sunday Iyanu Ajayi

unread,
Sep 11, 2020, 7:11:31 AM9/11/20
to django...@googlegroups.com
From what I see, you what to host your webapp on two domain name (addresses)


Right???

Kasper Laudrup

unread,
Sep 11, 2020, 7:39:47 AM9/11/20
to django...@googlegroups.com
Hi Giovanni,

On 10/09/2020 23.58, Giovanni Silva wrote:
> */This doesn't work. /*
>
> NGINX - FILE
> server {
>     listen 81;
>     server_name www.aidacomunicacao.com.br

If I go to http://www.aidacomunicacao.com.br:81/ as you have configured
here, I see the default Django welcome page.

Is this not what you expected?

Kind regards,

Kasper Laudrup

Giovanni Silva

unread,
Sep 11, 2020, 10:26:25 AM9/11/20
to django...@googlegroups.com
No...
I want to access www.aidacomunicacao.com.br and I hope see the django webpage

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Kasper Laudrup

unread,
Sep 11, 2020, 10:45:01 AM9/11/20
to django...@googlegroups.com
Hi Giovanni,

On 11/09/2020 12.24, Giovanni Silva wrote:
> No...
> I want to access www.aidacomunicacao.com.br
> <http://www.aidacomunicacao.com.br> and I hope see the django webpage
>

Then don't listen on port 81, but use the default port 80 for
non-encrypted HTTP traffic.

Kind regards,

Kasper Laudrup

Julio Cojom

unread,
Sep 11, 2020, 6:43:00 PM9/11/20
to django...@googlegroups.com
It depends, some people use virtualenvs, so you need to install gunicorn in each project. 


this might help, just change dependencies install to fit your os.

In my case, I deploy multiple projects with the same python and dependencies install without virtualenv and made a little script, need improvement but it's enough to pull some project from a repo and install the app.

It take 3 params, repository, db name and domain name.
db name equals to project name in my case.







--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
test_deploy.txt
Reply all
Reply to author
Forward
0 new messages