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年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ