配置弹性魔豆阿帕奇 [英] Configure apache on elastic beanstalk

查看:253
本文介绍了配置弹性魔豆阿帕奇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与豆茎弹性Django的发展,我想提出两个修改Apache的配置:

I'm developing with django on elastic beanstalk and I want to make two changes to apache configuration:

1。
重定向www.domain.com到domain.com

1. redirect www.domain.com to domain.com

2。
重定向 http://domain.com 来的 https://domain.com

我没有与Apache配置体验,Google上搜寻它给了我,我应该把在的RewriteRules .htaccess文件的主意。

I don't have experience with apache configuration, googling it gave me the idea that I should put RewriteRules in .htaccess file.

例如:
<一href=\"http://stackoverflow.com/questions/6858492/how-to-force-https-on-amazon-elastic-beanstalk-without-failing-the-health-check\">How强制HTTPS在Amazon Elastic魔豆,而不会导致健康检查

我无法找到如何与弹性青苗配置(.ebextensions)做说明,我想简单地把一个.htaccess文件在我的根的Filder和部署,但没有奏效。

I couldn't find instructions on how to do it with elastic beanstalk configuration (.ebextensions), I tried to simply put a .htaccess file in my root filder and deploy but it didn't work.

有谁知道它是如何可能添加的RewriteRules弹性魔豆?

Does anyone know how it's possible to add the RewriteRules in elastic beanstalk?

推荐答案

这是一个简单的解决方案

this is an easy solution


  1. SSH到您的EC2实例

  2. /etc/httpd/conf.d/wsgi.conf的内容复制到本地文件名为wsgi.conf将被放置在你的应用程序的基本文件夹

  3. 编辑wsgi.conf的本地版本,并添加以下重定向规则中的&lt;虚拟主机>&LT; /虚拟主机>标签

  1. ssh into your EC2 instance
  2. copy the contents of /etc/httpd/conf.d/wsgi.conf into a local file called wsgi.conf which will be placed in the base folder of your application
  3. Edit the local version of wsgi.conf and add the following redirect rules within the < VirtualHost> < /VirtualHost> tags

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]


  • 更改 您正在使用一个健康检查页。

    编辑您的&LT;您的内部应用> .conf文件。 ebextensions 目录中添加一个容器命令复制这个版本wsgi.conf超过亚马逊的版本

    Edit your < app>.conf file inside your .ebextensions directory to add a container command to copy this version of wsgi.conf over Amazon’s version

    container_commands:
    01_syncdb:
      command: "django-admin.py syncdb --noinput" leader_only: true
    02_collectstatic:
      command: "django-admin.py collectstatic --noinput"
    03_wsgireplace:
      command: 'cp wsgi.conf /etc/httpd/conf.d/wsgi.conf'
    ...
    


  • 部署code。

  • Deploy the code.

    它应该工作,该文件将被更新正确每个部署。观看的唯一的事情是,如果亚马逊改变了他们对未来的基础wsgi.conf文件的内容,那么你的副本可能不再起作用。

    It should work and the file will be properly updated for each deployment. The only thing to watch for is if Amazon changes their base wsgi.conf file contents in the future, then your copy may no longer work.

    来源: rickchristianson

    这篇关于配置弹性魔豆阿帕奇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆