본문 바로가기
IT이야기

[중계서버] 프록시(Proxy) 구성 방법

by 너머스고(numusgo) 2024. 1. 30.

클라우드 구성하다보면 내/외부 구성하여 서비스를 하는경우가 있다. 

내부망에서는 외부 통신이 안되기 때문에 아래와 같이 종류에 따라 프록시(proxy)를 구성하여 AP서비스를 개발해야한다.

 

 

1)  소프트웨어별 기능 구현 선택

기능 구분 Apache NGINX SSH 스퀴드(Squid) 비고
포워드 프록시
(Forward Proxy)
O X X X  
리버스 프록시
(Reverse Proxy)
O O O O  
스트림(Stream) X O X X  
암호화 X X O X  

 

2. 아파치 ( ProxyPass, ProxPassRevers 예제) + Forward Proxy + Reverse Proxy 가능

LoadModule proxy_module modules/mod_proxy.so

ProxyRequests on
  ProxyPreserveHost On

  <Proxy *>
     Order deny,allow
     Allow from all
  </Proxy>


  ProxyPass /oauth2.0/authorize https://nid.naver.com/oauth2.0/authorize
  ProxyPassReverse /oauth2.0/authorize https://nid.naver.com/oauth2.0/authorize

  ProxyPass /oauth2.0/token https://nid.naver.com/oauth2.0/authorize
  ProxyPassReverse /oauth2.0/token https://nid.naver.com/oauth2.0/authorize

  ProxyPass /v1/nid/me https://openapi.naver.com/v1/nid/me
  ProxyPassReverse /v1/nid/me https://openapi.naver.com/v1/nid/me

 

 

3. JAVA OPTION 프록시 서버 설정 방법

프록시서버는 다른곳에 구성 한 이후 WAS에서 프로시 서버로 바로보게 하는 예시

export SDC_JAVA_OPTS="-Xmx1024m -Xms1024m -Dhttps.proxyUser=apache -Dhttps.proxyPassword=Apache123# -Dhttps.proxyHost=<프록시서버IP> -Dhttps.proxyPort=80 -server ${SDC_JAVA_OPTS}"

적용
export SDC_JAVA_OPTS="-Xmx1024m -Xms1024m -Dhttps.proxyUser=apache -Dhttps.proxyPassword=Apache123# -Dhttps.proxyHost=172.xx.xx.xxx -Dhttps.proxyPort=80 -server ${SDC_JAVA_OPTS}"

 

 

4. NGINX ( Revers Proxy + Stream )

리버스프록시와 스트링방식(DB 연결 또는 OS 원격 접근)등 기능하다.

 

stream
{
        server
        {
                listen 11521;
                proxy_pass 127.0.0.1:1521;
        }
}


http://nginx.org/en/docs/mail/ngx_mail_core_module.html

mail {
    server_name       mail.example.com;
    auth_http         localhost:9000/cgi-bin/nginxauth.cgi;

    imap_capabilities IMAP4rev1 UIDPLUS IDLE LITERAL+ QUOTA;

    pop3_auth         plain apop cram-md5;
    pop3_capabilities LAST TOP USER PIPELINING UIDL;

    smtp_auth         login plain cram-md5;
    smtp_capabilities "SIZE 10485760" ENHANCEDSTATUSCODES 8BITMIME DSN;
    xclient           off;

    server {
        listen   25;
        protocol smtp;
    }
    server {
        listen   110;
        protocol pop3;
        proxy_pass_error_message on;
    }
    server {
        listen   143;
        protocol imap;
    }
    server {
        listen   587;
        protocol smtp;
    }
}

 

5. java 소스

자바 옵션으로 해도 되도 소스내에서 프로시 기능 구현하여 프로식시버로 연결 할 수 있다.