我正在将Flask与NGINX和Gunicorn一起使用。 Ubuntu 18.04.02。
当我运行默认服务器Flask时,一切正常。
继续。连接Gunicorn后,请不要执行请求后的操作。但是,当我与3名工人var array=['alice','why'];
var already = [];
check(array);
function check(array){
var word = array[0].split("");
again(word)
}
function again(word){
newWord = word.join("");
console.log(word)
console.log(newWord)
console.log(typeof newWord)
already.push(newWord);
}
一起经营Gunicorn时,一切都奏效了。哎呀!
继续。连接NGINX。我的配置:
gunicorn --bind 0.0.0.0:5000 wsgi:app -w 3
/etc/nginx/nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-available/myproject
server {
listen 80;
server_name 157.230.103.16 www.157.230.103.16;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
include proxy_params;
proxy_pass http://unix:/home/root/blend/myproject.sock;
}
}
/etc/systemd/system/myproject.service
所有GET请求均正常运行。除了POST。
日志:
[Unit]
Description=Gunicorn instance to serve myproject
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/home/root/blend
Environment="PATH=/home/root/blend/flask/bin"
ExecStart=/home/root/blend/flask/bin/gunicorn --bind unix:myproject.sock wsgi:app -w 3
[Install]
WantedBy=multi-user.target
access.log
177.54.88.78 - - [04/Mar/2019:00:28:25 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
195.19.247.81 - - [04/Mar/2019:00:42:24 +0000] "GET / HTTP/1.1" 200 396 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537$
195.19.247.81 - - [04/Mar/2019:00:58:37 +0000] "GET / HTTP/1.1" 200 3278 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/53$
195.19.247.81 - - [04/Mar/2019:00:58:41 +0000] "GET /members/ HTTP/1.1" 500 291 "http://157.230.103.16/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) C$
195.19.247.81 - - [04/Mar/2019:01:00:01 +0000] "GET / HTTP/1.1" 200 3278 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/53$
...
195.19.247.81 - - [04/Mar/2019:01:38:21 +0000] "GET /members/ HTTP/1.1" 500 291 "http://157.230.103.16/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) C$
95.213.177.126 - - [04/Mar/2019:01:41:00 +0000] "POST http://check.proxyradar.com/azenv.php?auth=155166365977&a=PSCMN&i=2649122576&p=80 HTTP/1.1" 404 580 "https://proxyradar.com/" "Mozilla/4.0 ($
152.249.19.127 - - [04/Mar/2019:01:41:08 +0000] "GET / HTTP/1.1" 200 8623 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
46.236.65.228 - - [04/Mar/2019:01:46:03 +0000] "GET / HTTP/1.1" 200 8623 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36"
...
error.log
在/成员页面上,成员向同一服务器/发出POST请求。但是在日志中却不是。 为什么没有POST请求?