I have an app which serves a dynamic html and some static files written in NodeJS/Express.
I deployed an AWS CloudFront distro in front of it, however only the HTML goes through, all the static files result in 404. The headers of the requests look like:
Age:116
Connection:keep-alive
Content-Length:170
Content-Security-Policy:default-src 'self'
Content-Type:text/html; charset=utf-8
Date:Mon, 09 Oct 2017 14:37:23 GMT
Server:nginx/1.6.2
Via:1.1 523db8f46d98334ac6b5debbf315e15b.cloudfront.net (CloudFront), 1.1 proxy1.xxx.yy (squid/4.0.17)
X-Amz-Cf-Id:5UYpluGn8TxUxsxmmDYYiZnjbOWbZ7iFFit55mmgcN6IbAJHCEAX6Q==
X-Cache:MISS from proxy1.xxx.yy
X-Cache:Error from cloudfront
X-Cache-Lookup:MISS from proxy1.xxx.yy:3128
X-Content-Type-Options:nosniff
X-Powered-By:Express
For info, my nodejs app runs in some port, and nginx reverse-proxies it to the domain I specified using proxy_pass
.
As you can see I'm behind another proxy, but this cannot be the problem.
What I believe is happening is that my origin looks like mydomain.com/path/app_id
and express serves static files from mydomain.com/
.
Has anyone successfully deployed CloudFront in front of NodeJS/Express for static files? I really don't understand what the problem is..
Thanks!