Information Security Study
nginx 연동하기 본문
nginx 연동하기
sudo apt-get update
sudo apt-get install -y curl gnupg2 ca-certificates lsb-release
sudo apt-get install -y ubuntu-keyring
curl -s https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
sudo apt-get update
sudo apt-get install -y nginx
nginx -v
설치 확인
sudo systemctl start nginx
버전 확인 후 위 명령어를 입력해서 nginx를 가동한다.
플로팅 ip로 둘 다 접속에 성공했다!
그리고 nginx가 app을 대신 보여주기 위해 설정을 수정해야 한다.
sudo vi /etc/nginx/nginx.conf
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
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"'
'backend_server=$upstream_addr';
upstream cpu-bound-app {
server app의ip:8080 weight=100 max_fails=3 fail_timeout=3s;
}
server {
location / {
proxy_pass http://cpu-bound-app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
}
app의 ip와 포트번호를 입력하고 저장한 뒤 나와
sudo systemctl reload nginx
nginx 설정 파일을 재입력해 줘야 한다.
'네트워크 캠퍼스 > 2차 프로젝트' 카테고리의 다른 글
private 인스턴스 bastion로 접속하기 (0) | 2024.07.18 |
---|---|
gradle 툴, ssh over, ssh agnet 플러그인 설치 (0) | 2024.07.18 |
젠킨스 브라우저 접속하기 (0) | 2024.07.18 |
jenkins 설치, 자바 설치, 도커 설치 (0) | 2024.07.18 |
subnet 구조 잡기 (0) | 2024.07.18 |