【问题标题】:How can i setup nginx upload module for Tornado framework我如何为 Tornado 框架设置 nginx 上传模块
【发布时间】:2018-08-14 11:15:38
【问题描述】:

我有一个使用 tornado framework.uploaded 文件在内存中创建的 web 服务。我想改为流式传输数据。所以我开始使用nginx upload module 流式传输数据。

我的 nginx 配置:

user nginx;    
worker_processes 1;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;

events {
    worker_connections 1024;
    use epoll;
}

http {
    # Enumerate all the Tornado servers here
    upstream frontends {
        server 127.0.0.1:8888;
    }
include /etc/nginx/mime.types;
default_type application/octet-stream;

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

keepalive_timeout 65;
proxy_read_timeout 200;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/html text/css text/xml
           application/x-javascript application/xml
           application/atom+xml text/javascript;

# Only retry if there was a communication error, not a timeout
# on the Tornado server (to avoid propagating "queries of death"
# to all frontends)
proxy_next_upstream error;

server {
    listen 80;

    # Allow file uploads
    client_max_body_size 50M;

    location ^~ /static/ {
        root /var/www;
        if ($query_string) {
            expires max;
        }
    }
    location = /favicon.ico {
        rewrite (.*) /static/favicon.ico;
    }
    location = /robots.txt {
        rewrite (.*) /static/robots.txt;
    }

    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_pass http://frontends;
    }
}

}

我收到此错误:

nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed

我测试了 nginx 上传模块的另一个配置,但是 nginx.service 没有正确重启。

有什么帮助吗?

【问题讨论】:

    标签: nginx tornado


    【解决方案1】:
    nginx: [emerg] getpwnam("nginx") failed in /etc/nginx/nginx.conf:1
    

    此错误表示您的系统上不存在名为 nginx 的用户。但是,您可以专门为您的服务器创建一个名为 nginx 的用户,如下所示:

    sudo useradd -r -s /bin/false nginx
    

    代码取自 - https://askubuntu.com/a/29364/364011

    user 参数不是运行 Nginx 所必需的。 By default Nginx runs under nobody user。因此,您可以从配置文件中省略 user 参数。

    最后,在 Ubuntu 中默认存在一个 www-data 用户,专门用于 Web 服务器。如果这是您正在运行的内容,您可以直接使用它,而不必创建新用户:

    user: www-data;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-09-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多