728x90
반응형
S3와 Docker 없이 동일한 EC2에 FastAPI, SpringBoot 배포하기
[AWS] AWS로 동시 배포/ FastAPI, Spring Boot 같은 EC2에 배포/ Nginx/ S3와 Docker 사용 X
S3와 Docker 없이 동일한 EC2에 FastAPI, SpringBoot 배포하기1. 동일한 EC2에 FastAPI, Spring Boot 프로젝트 git clone EC2 복사 EC2에서 프로젝트 git clone 1. jar 파일 빌드 -> EC2 복사 JDK 설치 $ sudo apt-get update $ sudo apt-
debug.tistory.com
프로젝트 깃 클론
Spring Boot와 동일
[AWS] AWS로 Spring Boot 배포 3/ java jar 파일 빌드/ git clone/ EC2 Timezone KST로 변경/ 서버 날짜 설정
실행 방법 2가지 jar 파일 빌드 -> EC2 복사 EC2에서 프로젝트 git clone 1. jar 파일 빌드 -> EC2 복사 JDK 설치 $ sudo apt-get update $ sudo apt-get install openjdk-17-jdk Spring Boot 프로젝트 빌드 프로젝트 파일 위치로
debug.tistory.com
프로젝트 빌드
프로젝트 파일 위치로 이동 후 빌드 -> build/index.html 생성
npm run build
nginx 설정 파일 내용 수정
CORS와 timeout 설정
server {
listen 80;
server_name {탄력적 IP};
location / {
root /home/ubuntu/Tusori_Frontend/build;
index index.html;
try_files $uri $uri/ /index.html;
}
location /springboot/ {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# CORS 관련 헤더 설정
add_header 'Access-Control-Allow-Origin' '{탄력적 IP}' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' '*' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
# Timeout 설정 추가
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
keepalive_timeout 60s;
}
location /fastapi/ {
proxy_pass http://localhost:8000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# CORS 관련 헤더 설정
add_header 'Access-Control-Allow-Origin' '{탄력적 IP}' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always;
add_header 'Access-Control-Allow-Headers' '*' always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
# Timeout 설정 추가
proxy_connect_timeout 60s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
keepalive_timeout 60s;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
728x90
반응형
'☁️' 카테고리의 다른 글
Kubernetes/ Helm (0) | 2025.02.23 |
---|---|
Docker (0) | 2025.02.23 |
[AWS] AWS로 동시 배포 1/ FastAPI, Spring Boot 같은 EC2에 배포/ Nginx/ S3와 Docker 사용 X (2) | 2024.07.17 |
[AWS] AWS로 Fast API 배포/ Python/ Uvicorn/ 백그라운드 실행/ 주식 데이터/ 주식 라이브러리/ FinanceDataReader/ Pykrx (0) | 2024.07.17 |
[AWS] AWS로 Spring Boot 배포 3/ java jar 파일 빌드/ git clone/ EC2 Timezone KST로 변경/ 서버 날짜 설정 (0) | 2024.03.20 |