【问题标题】:Config nginx with nodejs, don't work with upload file POST request?用 nodejs 配置 nginx,不支持上传文件 POST 请求?
【发布时间】:2014-06-20 07:37:17
【问题描述】:

我正在尝试使用 nodejs(sails.js 框架)配置 nginx。 Nginx 在 80 端口监听请求并传递到 8080。除了上传文件 post 请求之外,所有请求都可以正常工作(都是 post)。

下面是我的 nginx 配置文件:

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off
        upstream node {
         # One failed response will take a server out of circulation for 20 seconds.
         server localhost:8080 fail_timeout=20s;
                 keepalive 512;
    }
        server {
         listen 80 default_server;
         listen 8191;
         listen 443 ssl;
         ssl    on;
         ssl_certificate    /home/ubuntu/APP/cert.pem;
         ssl_certificate_key     /home/ubuntu/APP/key.pem;
         server_name localhost;

         location / {
            proxy_pass https://localhost:8080;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            # define buffers, necessary for proper communication to prevent 502s
        proxy_buffer_size 128k;
        proxy_buffers 4 256k;
        proxy_busy_buffers_size 256k;
            }
        }
    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

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

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";

    # gzip_vary on;
    # gzip_proxied any;
    # gzip_comp_level 6;
    # gzip_buffers 16 8k;
    # gzip_http_version 1.1;
    # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    ##
    # nginx-naxsi config
    ##
    # Uncomment it if you installed nginx-naxsi
    ##

    #include /etc/nginx/naxsi_core.rules;

    ##
    # nginx-passenger config
    ##
    # Uncomment it if you installed nginx-passenger
    ##

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

【问题讨论】:

    标签: node.js nginx sails.js


    【解决方案1】:

    您是否尝试取消注释这些行?

    #passenger_root /usr;
    #passenger_ruby /usr/bin/ruby;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-13
      • 2016-05-14
      • 2014-09-18
      • 1970-01-01
      • 2020-04-08
      • 2021-08-21
      • 2021-12-31
      • 2021-08-10
      相关资源
      最近更新 更多