[NCP] VPC 3tier 환경 구축 web - was

이정훈·2023년 11월 13일
0

NCP

목록 보기
2/3

1. web(nginx)

  • 사설 IP 172.16.100.6
  • 공인 IP 175.106.97.154
    (지정된 IP만 접속할 수 있기 때문에 현재 공개해도 무관하다!)

설치

apt update
apt-cache search nginx
apt install nginx -y

확인


systemctl status nginx

접속

  • 175.106.97.154:80

2. was(tomcat)

  • 사설 IP 172.16.200.6
  • web에서 SSH 접속을 통해 들어간다

설치

apt update
apt-cache search tomcat
apt install tomcat9 -y

확인

systemctl status tomcat9

3. web-was 연동

web(nginx) 설정

  • Nginx에서 사용되는 역방향 프록시 설정
  • Nginx에 들어오는 요청을 was(tomcat9) 서버의 8080포트로 전달 요청
vi /etc/nginx/sites-available/default

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ =404;
                
                # 추가 !!
                proxy_pass http://172.16.200.6:8080;
                # 여기에 사용된 IP는 was서버의 IP이다!
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $http_host;
        }

접속

  • 공인IP로 접속을 하면 tomcat으로 연결

  • 여기 /var/lib/tomcat9/webapps/ROOT 이 경로에서 jsp 파일을 날려 db와의 연결을 확인할 것이다!
profile
싱숭생숭늉

0개의 댓글