본문 바로가기

AWS Cloud School

[04.19] Proxy Server, 3-tier architecture

 

 

Proxy 서버 구축 실습

 

https://tomcat.apache.org/download-10.cgi

 

wget https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.23/bin/apache-tomcat-10.1.23.zip

 

 

 

cat <<EOF > index.jsp
<%@ page contentType="text/html; charset=UTF-8"%>
<html>
       <head><title>hello world</title></head>
       <body>
       <h2>
               TOMCAT TEST<br><br>
               time : <%= new java.util.Date()%>
               <%@ page import="java.net.InetAddress" %><br>
               <%InetAddress inet= InetAddress.getLocalHost();%>
               WAS ip : <%=inet.getHostAddress()%>
       </h2>
 
 
       </body>
</html>
EOF

 

 

 

아래 코드를 복사해서 붙여넣기 하자!!

 

cat <<EOF > dbtest.jsp

 

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ page import="java.sql.*"%>

<h1>DB</h2>

<%

        Connection conn=null;

        try{

                String Url="jdbc:mysql://<DB주소>/<DB이름>";

                String Id="<DB유저>";

                String Pass="<유저암호>";

 

                Class.forName("com.mysql.jdbc.Driver");

                conn=DriverManager.getConnection(Url,Id,Pass);

                out.println("was-db Connection Success!");

        }catch(Exception e) {

                e.printStackTrace(); 

}

%>

 

EOF

 

 

 

 

wget https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.25/mysql-connector-java-8.0.25.jar

 

 

 

 

아래의 코드를 복사해서 붙여넣기 하자!!

 

 

LoadModule proxy_connect_module modules/mod_proxy_connect.so

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_http_module modules/mod_proxy_http.so

 

<VirtualHost *:80> # 80번 포트로 들어오는 모든 Ip에 대한 설정

    ProxyRequests Off

    ProxyPreserveHost On

    <Proxy *> 

        Order deny,allow

        Allow from all

    </Proxy>

 

    ProxyPass /tomcat http://211.183.3.222:8080/ disablereuse=on

    ProxyPassReverse /tomcat http://211.183.3.222:8080/

</VirtualHost>

 

 

 

 

 

 

 

3-tier architecture 구축 실습