http2不适用于nginx 1.12 - debian8

时间:2017-09-27 06:18:26

标签: nginx gunicorn http2 nginx-reverse-proxy

我在http2上设置了nginx。以下代码段是sites-available目录中的nginx虚拟主机:

upstream mysite {
   server unix:/home/user/myproject/mysite.sock fail_timeout=0;
}

server {
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2;
    server_name www.mysite.com;
    ssl on;
    ssl_certificate /etc/nginx/ssl/mysite.com.chained.crt;
    ssl_certificate_key /etc/nginx/ssl/mysite.com.key;

    client_max_body_size 4G;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/user/myproject;
        expires 1d;
    }

#    access_log /opt/simple_academy/logs/nginx-access.log;
#    error_log /opt/simple_academy/logs/nginx-error.log;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;  # <-
        proxy_set_header Host $http_host;
        proxy_redirect off;

        if (!-f $request_filename) {
           proxy_pass http://mysite;
           break;
        }
    }
}

这里的nginx是反向代理,主网络服务器是Gunicorn,用于提供Django代码。 当我使用Chrome或Firefox检查元素测试网站时,它会将所有连接协议显示为HTTP1.1。 我该如何解决这个问题呢?

更新 以下是nginx -V命令的结果:

  

- prefix = / etc / nginx --sbin-path = / usr / sbin / nginx --modules-path = / usr / lib / nginx / modules --conf-path = / etc / nginx / nginx。 conf --error-log-path = / var / log / nginx / error.log --http-log-path = / var / log / nginx / access.log --pid-path = / var / run / nginx。 pid --lock-path = / var / run / nginx.lock --http-client-body-temp-path = / var / cache / nginx / client_temp --http-proxy-temp-path = / var / cache / nginx / proxy_temp --http-fastcgi-temp-path = / var / cache / nginx / fastcgi_temp --http-uwsgi-temp-path = / var / cache / nginx / uwsgi_temp --http-scgi-temp-path = / var / cache / nginx / scgi_temp --user = nginx --group = nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module - -with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module - -with-http_sub_module --with-http_v2_mod ule --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt =&#39; -g -O2 -fstack- protector-strong -Wformat -Werror = format-security -Wp,-D_FORTIFY_SOURCE = 2 -fPIC&#39; --with-ld-opt =&#39; -Wl,-z,relro -Wl,-z,now -Wl, - as-needed -pie&#39;

0 个答案:

没有答案