I'm learning nginx and uwsgi to deploy my Django web app. While learning them, I got confused with "socket" and "http".
I think I should write .ini
like the following.
when I use only uwsgi ... http=127.0.0.1:8001 ...
when I use uwsgi and nginx and I want to make clients connect to my server through nginx ... socket=127.0.0.1:8001 ...
When I only use uwsgi to run my server, I guess I should use "http" instead of "socket"
in .ini
file
http=127.0.0.1:8001
because if i use "socket" it emits errors when clients connect to my server, like this.
invalid request block size: 21573 (max 4096)...skip
However, when I use nginx with uwsgi, I should use socket
instead of http
.
If I use http
, I guess the server emitted timeout error.
My codes
this is my codes that works in /etc/nginx/sites-available/blog.conf
upstream blog{
server 127.0.0.1:8001;
}
server {
listen 80;
server_name 127.0.0.1;
charset utf-8;
client_max_body_size 75M; # adjust to taste
location /static {
alias /django_static/djProject;
}
location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass blog;
}
}
in project directory, app.ini
[uwsgi]
plugins=python3
chdir={myProject location}
module=djProject.wsgi:application
# Settings module, relative to the chdir path
env='DJANGO_SETTINGS_MODULE=djProject.settings'
# Python virtual env path
home=/home/su/uwsgi/uwsgi-tutorial
# File used for uwsgi to send signals and start/stop
socket=127.0.0.1:8001
#http=127.0.0.1:8001
master=True
processes=4
harakiri=20
max-requests=5
vacuum=True
enable-threads=true
static-map = /static=/django_static/djProject
In conclusion
How different are they to use http
and socket
in .ini
file and when should I use them respectively?