Elastic Beanstalk Node Static Files are not Loaded

0

I am having trouble serving my static files on Elastic Beanstalk using NodeJS deployed on Linux 2. My local environment works, but my deployment is unable to serve the static files located in a top-level static folder called 'public'.

My configuration is as follows:

option_settings:
  aws:elasticbeanstalk:environment:proxy:staticfiles:
    /images: public/images
    /javascripts: public/javascripts
    /stylesheets: public/stylesheets

I am certain that the configuration is processed correctly because I can view the results of the static file configuration within AWS UI. When I navigate to the home directory of my site (using http:// protocol), the HTML page is loaded, but the CSS and JS under the public directory is not. The error I get is as follows:

GET https://<domain name>/stylesheets/layout.css net::ERR_CONNECTION_TIMED_OUT

Note that the https:// protocol is used. From my understanding, the reason my local environment works is that my application serves the static files with the correct protocol. Here are my questions:

  1. Why are my static files being served with protocol https:// when I request my home directory using http://?
  2. I don't want to serve my static files through the application to reduce the number of requests to my application, noted here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-environmentproxystaticfiles. Is there anything actually wrong with the configuration?
질문됨 2년 전201회 조회
1개 답변
0

Issue was resolved. I am using Helmet JS for Content Security Policy (CSP), and it has a directive for converting insecure requests to secure ones: 'upgrade-insecure-requests'. Make sure to remove that in the development phase for a site that is relying on http:// for content. Best practice is to use https:// when possible.

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠