Djangoroidの奮闘記

python,django,angularJS1~三十路過ぎたプログラマーの奮闘記

Elastic Bean stalk で、django+s3+postgresqlをデプロイする。後編

概要

Elastic Bean stalk で、django+s3+postgresqlをデプロイする。後編

参考サイト

realpython.com

やってみたこと

Apache Configの設定

BeanStalkはApache使っているので、クライアントPCからの読み込みなどの設定を高速にするには、apacheのセットアップが必要。.ebextensions/03_apache.configを追加する。

container_commands:
  01_setup_apache:
    command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"

.ebextensions/enable_mod_deflate.confをコピーして、/etc/httpd/conf.d/enable_mod_deflate.confとして保存する」という内容のcommand。

次は、enable_mod_deflate.confを追記する。これは参考サイトをそのままコピペしてみる。

# mod_deflate configuration
<IfModule mod_deflate.c>
  # Restrict compression to these MIME types
  AddOutputFilterByType DEFLATE text/plain
  AddOutputFilterByType DEFLATE text/html
  AddOutputFilterByType DEFLATE application/xhtml+xml
  AddOutputFilterByType DEFLATE text/xml
  AddOutputFilterByType DEFLATE application/xml
  AddOutputFilterByType DEFLATE application/xml+rss
  AddOutputFilterByType DEFLATE application/x-javascript
  AddOutputFilterByType DEFLATE text/javascript
  AddOutputFilterByType DEFLATE text/css
  # Level of compression (Highest 9 - Lowest 1)
  DeflateCompressionLevel 9
  # Netscape 4.x has some problems.
  BrowserMatch ^Mozilla/4 gzip-only-text/html
  # Netscape 4.06-4.08 have some more problems
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  # MSIE masquerades as Netscape, but it is fine
  BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
<IfModule mod_headers.c>
  # Make sure proxies don't deliver the wrong content
  Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>

これでやってみる。

$ git add .
$ git commit
$ eb deploy

とりあえず、うまくいった!