perry_lin 2020-03-31 15:48 采纳率: 100%
浏览 248
已采纳

nginx 400错误,哪位大佬救救我

nginx配置信息

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format main '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log /var/log/nginx/access.log main;

    client_header_buffer_size 128k;
    large_client_header_buffers 4 128k;

    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;
        include /etc/nginx/conf.d/*.conf;

    upstream app_server {

    # for UNIX domain socket setups
    server unix:/webapps/learning_log/gunicorn.sock fail_timeout=0;

    }
    server {
        charset utf-8;
        listen 80;
        server_name www.xxxxxxxxxxxx.tk;

        # 日志
        access_log /webapps/learning_log/logs/nginx.access.log;
        error_log /webapps/learning_log/logs/nginx.error.log;

        # 不记录访问不到 favicon.ico 的报错日志
        location = /favicon.ico { access_log off; log_not_found off; }

        # static 和 media 的地址
        location /static {#注意!!!:static后面不能有/斜杠,否则会导致静态文件404
            alias /webapps/learning_log/static;
        }
        location /media {
            alias /webapps/learning_log/media;
        }


        location / {
            proxy_pass http://app_server;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        }
    }

    server {
        listen 80;
        server_name xxxxxxxxxxxx.tk;
        rewrite ^(.*) http://www.xxxxxxxxxxxx.tk$1 permanent;
    }

gunicorn_start.sh

#!/bin/bash
NAME='learning_log'
DJANGODIR=/webapps/learning_log
SOCKFILE=/webapps/learning_log/gunicorn.sock
USER=jbt
GROUP=webapps
NUM_WORKERS=3
DJANGO_SETTINGS_MODULE=learning_log.settings
DJANGO_WSGI_MODULE=learning_log.wsgi
LOG_DIR=/webapps/learning_log/logs

echo "starting $NAME ad 'whoami'"

cd $DJANGODIR
source ./11_env/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH

RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR


exec ./11_env/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
    --name $NAME \
    --workers $NUM_WORKERS \
    --user=$USER --group=$GROUP \
    --log-level=debug \
    --bind=unix:$SOCKFILE \
    --access-logfile=${LOG_DIR}/gunicorn_access.log

gunicorn_access.log(每行除时间不一样其他一模一样)

- - [01/Apr/2020:02:24:16 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"

nginx_access.log(每行除时间不一样其他一模一样)

xxx.xxx.xxx.x - - [01/Apr/2020:10:24:16 +0800] "GET / HTTP/1.1" 400 37 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"

gunicorn日志

arting learning_log ad 'whoami'
[2020-04-01 10:22:35 +0800] [98657] [DEBUG] Current configuration:
  config: None
  bind: ['unix:/webapps/learning_log/gunicorn.sock']
  backlog: 2048
  workers: 3
  worker_class: sync
  threads: 1
  worker_connections: 1000
  max_requests: 0
  max_requests_jitter: 0
  timeout: 30
  graceful_timeout: 30
  keepalive: 2
  limit_request_line: 4094
  limit_request_fields: 100
  limit_request_field_size: 8190
  reload: False
  reload_engine: auto
  reload_extra_files: []
  spew: False
  check_config: False
  preload_app: False
  sendfile: None
  reuse_port: False
  chdir: /webapps/learning_log
  daemon: False
  raw_env: []
  pidfile: None
  worker_tmp_dir: None
  user: 997
  group: 995
  umask: 0
  initgroups: False
  tmp_upload_dir: None
  secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
  forwarded_allow_ips: ['127.0.0.1']
  accesslog: /webapps/learning_log/logs/gunicorn_access.log
  disable_redirect_access_to_syslog: False
  access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
  errorlog: -
  loglevel: debug
  capture_output: False
  logger_class: gunicorn.glogging.Logger
  logconfig: None
  logconfig_dict: {}
  syslog_addr: udp://localhost:514
  syslog: False
  syslog_prefix: None
  syslog_facility: user
  enable_stdio_inheritance: False
  statsd_host: None
  statsd_prefix: 
  proc_name: learning_log
  default_proc_name: learning_log.wsgi:application
  pythonpath: None
  paste: None
  on_starting: <function OnStarting.on_starting at 0x7f398997a8c8>
  on_reload: <function OnReload.on_reload at 0x7f398997a9d8>
  when_ready: <function WhenReady.when_ready at 0x7f398997aae8>
  pre_fork: <function Prefork.pre_fork at 0x7f398997abf8>
  post_fork: <function Postfork.post_fork at 0x7f398997ad08>
  post_worker_init: <function PostWorkerInit.post_worker_init at 0x7f398997ae18>
  worker_int: <function WorkerInt.worker_int at 0x7f398997af28>
  worker_abort: <function WorkerAbort.worker_abort at 0x7f39896f50d0>
  pre_exec: <function PreExec.pre_exec at 0x7f39896f51e0>
  pre_request: <function PreRequest.pre_request at 0x7f39896f52f0>
  post_request: <function PostRequest.post_request at 0x7f39896f5378>
  child_exit: <function ChildExit.child_exit at 0x7f39896f5488>
  worker_exit: <function WorkerExit.worker_exit at 0x7f39896f5598>
  nworkers_changed: <function NumWorkersChanged.nworkers_changed at 0x7f39896f56a8>
  on_exit: <function OnExit.on_exit at 0x7f39896f57b8>
  proxy_protocol: False
  proxy_allow_ips: ['127.0.0.1']
  keyfile: None
  certfile: None
  ssl_version: 2
  cert_reqs: 0
  ca_certs: None
  suppress_ragged_eofs: True
  do_handshake_on_connect: False
  ciphers: TLSv1
  raw_paste_global_conf: []
[2020-04-01 10:22:35 +0800] [98657] [INFO] Starting gunicorn 19.8.1
[2020-04-01 10:22:35 +0800] [98657] [DEBUG] Arbiter booted
[2020-04-01 10:22:35 +0800] [98657] [INFO] Listening at: unix:/webapps/learning_log/gunicorn.sock (98657)
[2020-04-01 10:22:35 +0800] [98657] [INFO] Using worker: sync
[2020-04-01 10:22:35 +0800] [98662] [INFO] Booting worker with pid: 98662
[2020-04-01 10:22:35 +0800] [98663] [INFO] Booting worker with pid: 98663
[2020-04-01 10:22:35 +0800] [98665] [INFO] Booting worker with pid: 98665
[2020-04-01 10:22:35 +0800] [98657] [DEBUG] 3 workers
[2020-04-01 02:24:14 +0000] [98663] [DEBUG] GET /
[2020-04-01 02:24:16 +0000] [98665] [DEBUG] GET /
[2020-04-01 06:44:58 +0000] [98665] [DEBUG] GET /
[2020-04-01 06:45:00 +0000] [98665] [DEBUG] GET /

gunicorn_access.log

 - - [31/Mar/2020:06:41:37 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:06:41:52 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:06:50:36 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:07:07:27 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:07:08:09 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:07:22:25 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:07:33:12 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:07:33:17 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:14:02 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:14:04 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:14:11 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:14:45 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:05 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:09 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:09 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:10 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:10 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:11 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:11 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:12 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:12 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:13 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:08:15:32 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [31/Mar/2020:10:30:16 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [01/Apr/2020:01:57:37 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [01/Apr/2020:02:15:23 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [01/Apr/2020:02:22:13 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [01/Apr/2020:02:24:15 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [01/Apr/2020:02:24:16 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [01/Apr/2020:06:44:58 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
 - - [01/Apr/2020:06:45:00 +0000] "GET / HTTP/1.0" 400 26 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"

_
Bad Request (400)

Bad Request (400)

Bad Request (400)

  • 写回答

1条回答 默认 最新

  • weixin_43975295 2020-03-31 18:53
    关注

    报错里给了提示:connect() to unix:/webapps/learning_log/gunicorn.sock failed (2: No such file or directory)。提示没有找到这个东西。
    然后再看后面:upstream: "http://unix:/webapps/learning_log/gunicorn.sock:/" upstream把请求转发到了这个地方,这个地方能访问么?确认下看看。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 系统 24h2 专业工作站版,浏览文件夹的图库,视频,图片之类的怎样删除?
  • ¥15 怎么把512还原为520格式
  • ¥15 MATLAB的动态模态分解出现错误,以CFX非定常模拟结果为快照
  • ¥15 求高通平台Softsim调试经验
  • ¥15 canal如何实现将mysql多张表(月表)采集入库到目标表中(一张表)?
  • ¥15 wpf ScrollViewer实现冻结左侧宽度w范围内的视图
  • ¥15 栅极驱动低侧烧毁MOSFET
  • ¥30 写segy数据时出错3
  • ¥100 linux下qt运行QCefView demo报错
  • ¥50 F1C100S下的红外解码IR_RX驱动问题