invalid request block size 21573 - python

I was reading the tutorial provided in
http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
This very tutorial is a great tutorial. I have been able to configure django server on my raspberry pi raspbian system, on my Ubuntu Desktop too.
Now I am trying to do the same on a Virtual Machine, Ubuntu 16.04, nginx server.
On the line,
uwsgi --socket :8001 --wsgi-file test.py
I get an error saying
invalid request block size 21573 on the terminal
I went through the uwsgi tutorial that said not to use --http for --socket;
Either way I have not been able to get my webserver running. Please help.
Nginx is currently serving a wordpress site on start.

With --socket option you have to use uwsgi module in nginx instead of proxy.

Related

Python-DjangoREST-uWSGi-nginx

This is my first time posting and its a pretty long question.
I'm a beginner and I've decided to learn and use Python and DjangoREST to build my first web application.
Unfortunately, I have a lot of issues that I'm not sure how to get answers to. Querying Google one at a time for each component is giving me answers that sometimes conflicts with another component.
First things first, the following is my project setup:-
OS->Ubuntu 16.04.1
Backend->Python3 and DjangoREST
Webserver->uWSGI and nginx
Database->PostgreSQL
Client Side software->AngularJS(which requires the setup of Node.js and NPM)
Now I installed pip and went through the process of creating a virtualenv and ran a test Django app. I was able to get that done.
When I went through the documentation of uWSGI and Nginx over here http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html, I came across the following line
the web client <-> the web server <-> the socket <-> uwsgi <-> Django
This has me slightly confused. Is there a specific order in which I need to install the software I need? And if yes, could you all tell me the correct order?
Thanks in advance!
This is not actually the order you should install software. This is the communication flow in which you(your browser) connect to the django application on your server.
To make work your application in your server you should do the followings:
First install nginx (reverse proxy server and a web server as well)
Install Gunicorn (wsgi server implementation)
Clone your django project in any directory from your remote git (or simply upload it from local pc)
now run the below command inside the project directory
gunicorn YOUR_PROJECT_NAME.wsgi:application \
--name GIVE_A_NAME_AS_YOUR_WISH \
--worker-connections=1000 \
--threads=3 \
--workers NUM_WORKERS \
--user=USER --group=GROUP \
--bind=SERVER_HOST:ANY_PORT_AS_YOUR_CHOICE (TYPICALLY IT IS 8000)
Point number 4 is enough to run your project in your server. check it in the below link
http://YOUR_HOST_ADDRESS:8000/
Now you can redirect all of your traffic to this application by nginx web server configuration. To do so make a file inside /etc/nginx/conf.d/ naming my_app.conf. inside this file copy paste the below code:
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:8000;
}
}
Hopefully it is okay !

How to persist UWSGI server on AWS after console closed

I'm a newcomer to web applications and AWS, so please forgive me if this is the answer is bit trivial!
I'm hosting a python web application on a AWS EC2 server using nginx + uWSGI. This is all working perfectly, except when I terminate my connection (using putty), my uWSGI application stops running, producing a "502 Bad Gateway" error from nginx.
I'm aware of adding the "&" to the uwsgi start up command (below), but that does not work after I close out my connection.
uwsgi --socket 127.0.0.1:8000 -master -s /tmp/uwsgi.sock --chmod-socket=666 -w wsgi2 &
How do I persist my uWSGI application to continue hosting my web app after I log out/terminate my connection?
Thanks in advance!
You'll typically want to start uwsgi from an init script. There are several ways to do this and the exact procedure depends on the Linux distribution you're using:
SystemV init script
upstart script (Ubuntu)
supervisor (Python-based process manager)
For the purposes of my use case, I will not have to reboot my machine in the near future, so Linux's nohup (no hangup) command works perfectly for this. It's a quick and dirty hack that's super powerful.

Error 404 when trying to access a Django app installed in a subdomain

I just installed Django and create a project and an app following the basic tutorial part 1, I created a virtualenv since centOS default python version is 2.4.3, I also created a subdomain to work on this for the development phase. when I try to access like dev.domain.com/admin/ or dev.domain.com/ I get a 404 error, it's like django is not even there. When I run the server I get a normal response:
(python2.7env)-bash-3.2# python manage.py runserver
Validating models...
0 errors found
February 22, 2014 - 23:54:07
Django version 1.6.2, using settings 'ct_project.settings'
Starting development server at http://127.0.0.1:8000/
Any ideas what I'm missing?
EDIT:after starting the server correctly(with the right ip) I tried again and as a result I got the browser hanging. Then I went to tried an online port scanner and found out that the port 8000 is not responding, any ideas what I can try next?
Thanks
You need to have you hosts entry on /etc/hosts like the following one
127.0.0.1 dev.domain.org
By default Django start the dev web server on port 8000 and you browser is looking for the server on port 80 (default port for webservers) so you need to add the port at the end of the url
http://dev.domain.com:8000.
if you want to start the server in default port 80 you need to specify it (migth need root or sudo):
python manage.py runserver http://dev.domain.com:80
The issue was solved by contacting the support service and asking them to open the port 8000 for me.

Deploy Bottle Application on Nginx

I have an Ubuntu 12.04 server setup that currently runs a Ruby on Rails application on a Passenger / Nginx install. I decided to play around with some Python and wrote a small application using Bottle. I would like to deploy this application to my server.
I followed this guide on setting up my server to run Python applications. When I run sudo service uwsgi restart I get the following error message:
Restarting app server(s) uwsgi
[uWSGI] getting INI configuration from
/usr/share/uwsgi/conf/default.ini [uWSGI] parsing config file /etc/uwsgi/apps-enabled/example.net.xml
open("./python_plugin.so"): No such file or directory [core/utils.cline 4700]
!!! UNABLE to load uWSGI plugin: ./python_plugin.so: cannot open shared object file: No such file or directory !!!
Sat Dec 8 18:29:14 2012 - [WARNING] option "app" is deprecated: use the more advanced "mount" option
I really don't know a ton about Python, I have installed the plugins I need via easy_install
Which are:
pymongo
beautifulsoup
bottle
My question is: how do I deploy this simple application to my server?
Thank you
I found out that Passenger will run WSGI apps. I followed the instructions on this post http://kbeezie.com/using-python-nginx-passenger/ and had no trouble getting it working.
It was actually pretty easy in the end.
Here is my adaptor in case anybody else has trouble:
https://github.com/nick-desteffen/astronomy-pics/blob/master/passenger_wsgi.py

django fastcgi can't run

I use fastcgi to run a django application. The command I use to run it is as follows:
python manage.py runfcgi method=threaded host=127.0.0.1 port=3035
If I input ps -ef|grep python I can see the thread also, but when i use lynx localhost:3035 to open it, I get a 504 gateway timeout.
So instead, now I use
python manage.py runserver 3035
and it runs OK. I don't know the reson. In the past, I use django 1.2 and it was OK.
my server info:
debian5.0, django1.3, python2.6
The FastCGI protocol is different from HTTP protocol. You need to add some layer talking both HTTP and FastCGI protocols, between lynx and devserver. For example nginx w/ FastCGI module configured.
If deploy with nginx, the better choices are gunicorn or uwsgi(supported natively by nginx).
gunicorn:
http://gunicorn.org/run.html
uwsgi
http://projects.unbit.it/uwsgi/wiki/Example

Categories

Resources