I have a dockerized Nginx reverse proxy to a nodejs app which is supposed to serve generated PDFs based on data entered.
Here's the current state of 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;
}
}
In the node app, the correct directory is mapped to the /file endpoint:
app.use('/files', express.static(path.join(__dirname, 'storage')));
However, when trying to load a PDF in browser, I get the following error message:
This site can’t provide a secure connectionlocalhost sent an invalid response.
ERR_SSL_PROTOCOL_ERROR
And the nginx container logs show:
172.23.0.1 - - [24/Oct/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\x01\x13\x02\x13\x03\xC0+\xC0/\xC0,\xC00\xCC\xA9\xCC\xA8\xC0\x13\xC0\x14\x00\x9C\x00\x9D\x00/\x005\x00" 400 157 "-" "-" "-"
The goal is to be able to test everything on localhost (hence no SSL), production environment would probably include an additional Nginx reverse-proxy in front of this one which handles certifcates etc.
I'd be very grateful for any pointers regarding how to serve PDFs in both environments.
Thanks in advance!