部分(但不是全部)由 nginx 代理的静态内容成功加载

部分(但不是全部)由 nginx 代理的静态内容成功加载

我在 Windows 机器上设置了 nginx 作为反向代理,通过 SSL 监听 443。当我访问某个特定的 URL 时,它应该为我在本地运行的 node js web 应用程序提供服务。它成功访问了该应用程序 - 但是,它加载了部分但不是全部的 web 应用程序静态内容。哪个每次文件未加载的情况都不同。

有几个 css 和 JavaScript 文件需要加载。当我检查 Chrome 中开发者工具的网络选项卡时,它显示两个文件无限期挂起,而其他文件已加载正常。哪两个文件有所不同每个时间。

开发者工具

这是我的 nginx.conf(为了保护隐私,我替换了实际的 URL):

worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  0;
    client_max_body_size 1024M;

    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;

    # time is in seconds
    proxy_connect_timeout       1000;
    proxy_send_timeout          1000;
    proxy_read_timeout          1000;
    send_timeout                1000;

    proxy_set_header    X-Real-IP $remote_addr;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header    Host $host;

    server {
        listen 443;
        ssl on;
        ssl_certificate cert.pem;
        ssl_certificate_key cert.key;
        ssl_verify_client optional_no_ca;
        server_name  v-mysite.com;

        error_log logs/error.log debug;

        location / {
            proxy_pass https://pm-mysite.com:4434;
        }

        location /mja/ {
            proxy_pass https://pm-mysite.com:4433;
        }

        location /mja/cassette.axd/ {
            proxy_pass https://pm-mysite.com:4433/cassette.axd/;
        }

        location /mja/content/ {
            proxy_pass https://pm-mysite.com:4433/Content/;
        }

        location /api/myappcenter/ {
            proxy_pass https://pm-mysite.com:4333/;
       }

        location /api/documentation/myappcenter {
            proxy_pass https://qa-mysite.com:4433/documentation;
        }

        location /api/person/match {
            proxy_pass https://anothersite.com:43443/match;
        }

        location /api/sms/ {
            proxy_pass https://anothersite.com:44443/;
        }

        location /myapp/content/ {
            proxy_pass http://pm-mysite.com:5000/;
            proxy_buffering off;
            proxy_set_header Connection keep-alive;
        }

        location /api/myapp/ {
            proxy_pass http://pm-mysite.com:5000/api/;
            proxy_buffering off;
            proxy_set_header Connection keep-alive;
        }

        location ~* ^/(?!api)(?<alias>\w+)/myapp/index/(?<path>.*)$ {
            proxy_pass http://pm-mysite.com:5000/$path;
            proxy_buffering off;
            proxy_set_header Connection keep-alive;
            proxy_set_header Alias $alias;
        }
    }
}

我已将 nginx 错误日志设置为调试,并在此处包含了(希望)相关的部分。可能发生了某种类型的 ssl 读取错误。

[debug] 9684#11312: *278 http process request line
[debug] 9684#11312: *278 http request line: "GET /myapp/content/js/resources.en.js HTTP/1.1"
[debug] 9684#11312: *278 http uri: "/myapp/content/js/resources.en.js"
[debug] 9684#11312: *278 http args: ""
[debug] 9684#11312: *278 http exten: "js"
[debug] 9684#11312: *278 http process request header line
[debug] 9684#11312: *278 http header: "Host: v-mysite.com"
[debug] 9684#11312: *278 http header: "Connection: keep-alive"
[debug] 9684#11312: *278 http header: "Cache-Control: max-age=0"
[debug] 9684#11312: *278 http header: "Accept: */*"
[debug] 9684#11312: *278 http header: "If-None-Match: "1d18a93e19632ee""
[debug] 9684#11312: *278 http header: "If-Modified-Since: Wed, 30 Mar 2016 14:53:12 GMT"
[debug] 9684#11312: *278 http header: "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36"
[debug] 9684#11312: *278 http header: "Referer: https://v-mysite.com/myapp/Index/AuLKHOtasdfasdfzGkmXOaUkAasdfL2uWQ"
[debug] 9684#11312: *278 http header: "Accept-Encoding: gzip, deflate, sdch"
[debug] 9684#11312: *278 http header: "Accept-Language: en-US,en;q=0.8,de;q=0.6"
[debug] 9684#11312: *278 http alloc large header buffer
[debug] 9684#11312: *278 malloc: 0237BEE0:8192
[debug] 9684#11312: *278 http large header alloc: 0237BEE0 8192
[debug] 9684#11312: *278 http large header copy: 493
[debug] 9684#11312: *278 SSL_read: 3577
[debug] 9684#11312: *278 SSL_read: -1
[debug] 9684#11312: *278 SSL_get_error: 2

我对 nginx 还很陌生,请对我宽容一点。:)

相关内容