# bottle+uwsgi+nginx ?



## BroodForge (Apr 17, 2016)

I'm a n00b using FreeBSD and having problems getting everything to work properly.

Installed www/nginx, www/uwsgi, and sysutils/py-supervisor based on instructions found here -

https://www.srijn.net/2015/03/django-uwsgi-nginx-on-freebsd/

However I am having difficulties getting my bottle app to display properly.

Running uwsgi alone with --ini myapp.ini works but with nginx I am getting 502 error.

My uwsgi file:

```
[uwsgi]
module = wsgihandler
socket = 127.0.0.1:3031
master = true
chmod-socket = 664
uid = www
gid = www
#enable-threads = true
proesses = 4
socket-timeout = 180
post-buffering = 8192
max-requests = 1000
buffer-size = 32768
wsgi-file = /usr/local/www/myapp/index.py
```
myapp.conf (inside conf.d folder)

```
upstream myapp {
least_conn;
server unix:///var/run/uwsgi_myapp0.sock;
server unix:///var/run/uwsgi_myapp1.sock;
server unix:///var/run/uwsgi_myapp2.sock;
server unix:///var/run/uwsgi_myapp3.sock;
server unix:///var/run/uwsgi_myapp4.sock;
}
server {
listen 3031;
server_name localhost;

location / {
uwsgi_pass myapp;
include uwsgi_params;
}
}
```
Anyone who can help a lost soul?


----------



## hukadan (Apr 17, 2016)

From a logical point of view and given your uwsgi file, I would expect to see something like the following in your myapp.conf file :

```
upstream myapp {
    server    127.0.0.1:3031 ;
}
```
since you do not use sockets.

--- Edit --
Or even shorter (see here):

```
location / {
    include uwsgi_params;
    uwsgi_pass 127.0.0.1:3031;
}
```


----------



## hukadan (Apr 17, 2016)

I just realized that your nginx server is listening on the same port than your application. You should set the nginx to listen on port *80* or at least not on *3031*. Have a look to the official documentation.


----------



## BroodForge (Apr 18, 2016)

hukadan said:


> I just realized that your nginx server is listening on the same port than your application. You should set the nginx to listen on port *80* or at least not on *3031*. Have a look to the official documentation.



Greetings,
Thanks for your replies and I really do appreciate it. Ports and sockets are all new to me =) I have started all over and instead of trying to follow online "how to" I am now starting from scratch, one thing at a time and reading. Will be writing back on my progress.
I have managed to run a bottle base app with uwsgi, now I need to configure nginx, and supervisor.


----------

