기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
Elastic Beanstalk는 nginx
기본적으로 Elastic Beanstalk는 요청을 포트 5000의 애플리케이션에 전달하도록 nginx 프록시를 구성합니다. PORT
환경 속성을 기본 애플리케이션이 수신 대기하는 포트로 설정하여 기본 포트를 재정의할 수 있습니다.
참고
애플리케이션이 수신 대기하는 포트는 nginx 서버가 로드 밸런서에서 요청을 받기 위해 수신 대기하는 포트에 영향을 주지 않습니다.
플랫폼 버전에서 프록시 서버 구성
모든 AL2023/AL2 플랫폼은 균일한 프록시 구성 기능을 지원합니다. AL2023/AL2를 실행하는 플랫폼 버전에서 프록시 서버를 구성하는 방법에 대한 자세한 내용은 역방향 프록시 구성 단원을 참조하세요.
Elastic Beanstalk Java SE 환경에서 Amazon Linux AMI 플랫폼 버전(이전 Amazon Linux 2)을 사용하는 경우 여기의 추가 정보를 읽어 보십시오.
Notes
-
이 주제의 정보는 Amazon Linux AMI(AL1) 기반 플랫폼 브랜치에만 적용됩니다. AL2023/AL2 플랫폼 브랜치는 이전 Amazon Linux AMI(AL1) 플랫폼 버전과 호환되지 않으며 다른 구성 설정이 필요합니다.
-
2022년 7월 18일 Elastic Beanstalk는 Amazon Linux AMI(AL1) 에 기반한 모든 플랫폼 브랜치의 상태를 사용 중지로 설정했습니다. 완전 지원이 가능한 현재 Amazon Linux 2023 플랫폼 브랜치로 마이그레이션하는 방법에 대한 자세한 내용은 Elastic Beanstalk Linux 애플리케이션을 Amazon Linux 2023 또는 Amazon Linux 2로 마이그레이션을(를) 참조하세요.
Elastic Beanstalk의 기본 nginx 구성을 확장하려면 애플리케이션 소스 번들의 .conf
라는 폴더에 .ebextensions/nginx/conf.d/
구성 파일을 추가합니다. Elastic Beanstalk의 nginx 구성에는 이 폴더의 .conf
파일이 자동으로 포함됩니다.
~/workspace/my-app/
|-- .ebextensions
| `-- nginx
| `-- conf.d
| `-- myconf.conf
`-- web.jar
Elastic Beanstalk의 기본 nginx 구성을 완전히 재정의하려면 .ebextensions/nginx/nginx.conf
의 소스 번들에 구성을 포함시킵니다.
~/workspace/my-app/
|-- .ebextensions
| `-- nginx
| `-- nginx.conf
`-- web.jar
Elastic Beanstalk의 nginx 구성을 재정의하는 경우 nginx.conf
에 다음 줄을 추가하여 Elastic Beanstalk의 향상된 상태 보고 및 모니터링, 자동 애플리케이션 매핑 및 정적 파일에 대한 Elastic Beanstalk 구성을 가져옵니다.
include conf.d/elasticbeanstalk/*.conf;
Scorekeep 샘플 애플리케이션public
의 하위 디렉터리 /var/app/current
에 있는 정적 웹 애플리케이션을 제공합니다. /api
로케이션은 트래픽을 /api/
아래의 경로를 거쳐 포트 5000에서 수신 중인 Spring 애플리케이션으로 전달합니다. 다른 모든 트래픽은 루트 경로에 위치한 웹 앱을 통해 제공됩니다.
user nginx;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 33282;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
include conf.d/*.conf;
map $http_upgrade $connection_upgrade {
default "upgrade";
}
server {
listen 80 default_server;
root /var/app/current/public;
location / {
}git pull
location /api {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
access_log /var/log/nginx/access.log main;
client_header_timeout 60;
client_body_timeout 60;
keepalive_timeout 60;
gzip off;
gzip_comp_level 4;
# Include the Elastic Beanstalk generated locations
include conf.d/elasticbeanstalk/01_static.conf;
include conf.d/elasticbeanstalk/healthd.conf;
}
}