Dockerized Nginx反向代理到NodeJS应用的反向代理未返回PDF

时间:2019-10-24 14:57:11

标签: node.js docker nginx

我有一个nodejs应用程序的dockerized Nginx反向代理,应该根据输入的数据提供生成的PDF。

这是nginx.conf的当前状态

# nginx.conf

server {
    listen       80;
    server_name  localhost;
    root         /usr/share/nginx/html;
    include      /etc/nginx/mime.types;

    # bot
    location / {
        proxy_pass http://frontend:80;
        proxy_http_version 1.1;
        proxy_set_header X-Forwareded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_buffering off;
    }

    location /api {
        proxy_pass http://backend:3000;
        proxy_http_version 1.1;
        proxy_set_header X-Forwareded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_buffering off;
    }

    location /socket.io {
        proxy_pass http://backend:3000;
        proxy_http_version 1.1;
        proxy_set_header X-Forwareded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_buffering on;
        proxy_buffer_size 8k;
        proxy_buffers 8 8k;
    }

    location /files {
        proxy_pass http://backend:3000;
        proxy_http_version 1.1;
        proxy_set_header X-Forwareded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_buffering on;
        proxy_buffer_size 8k;
        proxy_buffers 8 8k;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}


在节点应用程序中,正确的目录映射到/file端点:

app.use('/files', express.static(path.join(__dirname, 'storage')));

但是,当尝试在浏览器中加载PDF时,出现以下错误消息:

  

该站点无法提供安全的连接,本地主机发送了无效的响应。

     

ERR_SSL_PROTOCOL_ERROR

nginx容器日志显示:

  

172.23.0.1--[24 /十月/ 2019:16:42:39 +0200]“ \ x16 \ x03 \ x01 \ x02 \ x00 \ x01 \ x00 \ x01 \ xFC \ x03 \ x03 \ xF7 \ x01 \ xBB \ x1E \ xD2 \ xAF * \ xB7 \ xFB \ xB96b4 \ xEE \ xEB \ xC9 \ x18u \ x94-`(\ xBA \ xB9'\ xC18o \ xA0n \ xA0 \ xDA \ xB2l〜n \ xDFd \ xB9 \ x02C /] \ x9C3 \ xD5u \ x19 \ xA7 \ xE3c \ x1D \ xFD \ x06 \ xEBv \ x0B \ x88x \ x8FW \ x9As \ x1F \ x00 \ x22 \ xDA \ xDA \ x13 \ x13 \ x01 \ x13 \ x02 \ x13 \ x03 \ xC0 + \ xC0 / \ xC0,\ xC00 \ xCC \ xA9 \ xCC \ xA8 \ xC0 \ x13 \ xC0 \ x14 \ x00 \ x9C \ x00 \ x9D \ x00 / \ x005 \ x00“ 400157”-“”- “”-“

目标是能够测试localhost上的所有内容(因此没有SSL),生产环境可能会在此环境之前包含一个额外的Nginx反向代理,用于处理证书等。

对于在两种环境中如何提供PDF的任何指示,我将不胜感激。

谢谢!

0 个答案:

没有答案