본문 바로가기
NGINX

[실습] AWS Nginx & TOMCAT 연동

by SAMSUNG CLOUD-OKY 2021. 5. 28.
반응형

## AWS PORXXX Nginx & TOMCAT 연동
    - 포탈 관리시스템 URL (http://3.XX.XX.XXX:8080)

  1. nginx 설치
    - $sudo apt-get install nginx
    - $sudo nginx -v
        nginx version: nginx/1.18.0 (Ubuntu)
    - $sudo service nginx start

  2. nginx와 tomcat 서버 연동
    - 이 웹서버의 설정파일은  /etc/nginx/nginx.conf 파일에서 내용 추가
  <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    61         upstream portal {
    62             server portal.koaXXX.ga:8080;
    63         }
    64
    66         include /etc/nginx/conf.d/*.conf;
    67         include /etc/nginx/sites-enabled/*;
  >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    - cd sites-available/ 디렉토리로 이동
    - root@ip-10-20-18-211:/etc/nginx/sites-available# cd sites-available/
    - vi portal 파일 편집
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   server {
       listen 80;
       listen [::]:80;

       server_name portal.koaXXX.ga;

#     server_name 3.37.33.xxx;       (IP주소로도 접속을 허용하려면 작성)

#       root /var/www/example.com;
#       index index.html;

       location / {
               proxy_pass http://portal;

               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;

               proxy_redirect  off;
               charset utf-8;

               index index.jsp;

#               try_files $uri $uri/ =404;   (넣으면 NGINX 에러 발생)
       }
}
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    - /sites-enables/ 로 가서 default 심볼릭링크 삭제
    - root@ip-10-20-18-211:/etc/nginx/sites-enabled# rm -rf default
    - sudo ln -s ../sites-available/portal portal     (심볼릭링크 재설정)

    - root@ip-10-20-18-211:/etc/nginx/sites-enabled# nginx -t   (OK사인 확인)


    - nginx 재시작
      : sudo nginx -s reload
    - nginx (80) 포트를 이용하여 -> tomcat (8080) 서버로 접속 가능


반응형

댓글