AWS ElasticBeanstalk Apache, NginX conf 추가하기

try.catch·2019년 12월 19일
0

회사 서비스 중에 GET 방식의 통신 중 Query String 이 아주 긴 요청을 처리 해야 하는데 Tomcat은 server.xml, Apache 는 conf 파일을 수정 하면 된다.

AWS ElasticBeanstalk 을 사용하고 있었기 때문에 .ebextensions을 사용해야 하는데 Apache나 NginX 는 conf 파일을 추가하거나 교체 하는 것이 아주 쉽다.

기본 Apache 구성 확장 및 재정의

Elastic Beanstalk의 기본 Apache 구성을 확장하려면 애플리케이션 소스 번들의 .ebextensions/httpd/conf.d라는 폴더에 .conf 구성 파일을 추가한다. Elastic Beanstalk의 Apache 구성에는 이 폴더의 .conf 파일이 자동으로 포함된다.

~/workspace/my-app/
|-- .ebextensions
|   -- httpd
|      -- conf.d
|         -- myconf.conf
|         -- ssl.conf
-- index.jsp

예를 들어, 다음 Apache 2.4 구성은 포트 5000에 리스너를 추가한다.

listen 5000
<VirtualHost *:5000>
  <Proxy *>
    Require all granted
  </Proxy>
  ProxyPass / http://localhost:8080/ retry=0
  ProxyPassReverse / http://localhost:8080/
  ProxyPreserveHost on

  ErrorLog /var/log/httpd/elasticbeanstalk-error_log
</VirtualHost>

Elastic Beanstalk의 기본 Apache 구성을 완전히 재정의하려면 .ebextensions/httpd/conf/httpd.conf의 소스 번들에 구성을 포함시킨다.

~/workspace/my-app/
|-- .ebextensions
|   `-- httpd
|       `-- conf
|           `-- httpd.conf
`-- index.jsp

기본 nginx 구성 확장

Elastic Beanstalk의 기본 nginx 구성을 확장하려면 애플리케이션 소스 번들의 .ebextensions/nginx/conf.d/라는 폴더에 .conf 구성 파일을 추가한다. Elastic Beanstalk nginx 구성에는 이 폴더의 .conf 파일이 자동으로 포함된다.

~/workspace/my-app/
|-- .ebextensions
|   `-- nginx
|       `-- conf.d
|           |-- elasticbeanstalk
|           |   `-- my-server-conf.conf
|           `-- my-http-conf.conf
`-- index.jsp

결론적으로 .ebextensions/httpd(nginx)/conf.d/ 폴더 밑에 conf 파일들을 위치 시키면 된다.

0개의 댓글