<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>구리의 창고</title>
    <link>https://dgoh.tistory.com/</link>
    <description></description>
    <language>ko</language>
    <pubDate>Tue, 2 Jun 2026 21:09:43 +0900</pubDate>
    <generator>TISTORY</generator>
    <ttl>100</ttl>
    <managingEditor>구리z</managingEditor>
    <image>
      <title>구리의 창고</title>
      <url>https://t1.daumcdn.net/cfile/tistory/246AED4C595463E70C</url>
      <link>https://dgoh.tistory.com</link>
    </image>
    <item>
      <title>AWS Site-To-Site VPN &amp;lt;&amp;gt; Openswan 연결</title>
      <link>https://dgoh.tistory.com/129</link>
      <description>&lt;h2 data-ke-size=&quot;size26&quot;&gt;개요&lt;/h2&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;AWS Site-To-Site VPN은 IPsec VPN 서비스이다. 운영환경에 이용하기 적합하지는 않지만, 이를 이용하면 온프렘과 네트워크를 연결하고 테스트 환경을 쉽게 구축 할 수 있다. 아래와 같이 가상의 온프렘을 AWS VPC와 EC2를 이용해 구축하고, TransitGateway를 통해 VPN과 연결한다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-origin-width=&quot;712&quot; data-origin-height=&quot;283&quot; data-ke-mobilestyle=&quot;widthOrigin&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/6NFSd/btrbUW7mhbW/KfguRakk0w68GRNokNpgY0/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/6NFSd/btrbUW7mhbW/KfguRakk0w68GRNokNpgY0/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/6NFSd/btrbUW7mhbW/KfguRakk0w68GRNokNpgY0/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2F6NFSd%2FbtrbUW7mhbW%2FKfguRakk0w68GRNokNpgY0%2Fimg.png&quot; data-origin-width=&quot;712&quot; data-origin-height=&quot;283&quot; data-ke-mobilestyle=&quot;widthOrigin&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h2 data-ke-size=&quot;size26&quot;&gt;Openswan&lt;/h2&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;오픈소스 기반의 IPsec VPN인 &lt;a href=&quot;https://openswan.org/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;Openswan&lt;/a&gt;을 이용해 환경을 구축해보려고한다. BGP 설정을 위해서는 더 많은 작업들이 필요하지만, 이 글에서는 Static route 기반으로 구축하도록한다.&lt;/p&gt;
&lt;h2 data-ke-size=&quot;size26&quot;&gt;단계1: AWS Site-To-Site VPN 생성&lt;/h2&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;Site-To-Site VPN과 TransitGateway를 아래와같이 terraform을 이용해 만들어준다. Openswan은 BGP를 지원하지 않으므로 &lt;b&gt;static_routes_only&lt;/b&gt; 옵션을 반드시 활성화 하도록 한다.&lt;/p&gt;
&lt;pre id=&quot;code_1628731884381&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;resource &quot;aws_ec2_transit_gateway&quot; &quot;this&quot; {
  auto_accept_shared_attachments  = &quot;enable&quot;
  default_route_table_association = &quot;disable&quot;
  default_route_table_propagation = &quot;disable&quot;
}

resource &quot;aws_ec2_transit_gateway_route_table&quot; &quot;this&quot; {
  transit_gateway_id = aws_ec2_transit_gateway.this.id
}

resource &quot;aws_customer_gateway&quot; &quot;this&quot; {
  bgp_asn    = 65000
  ip_address = aws_eip.onprem.public_ip
  type       = &quot;ipsec.1&quot;
}

resource &quot;aws_vpn_connection&quot; &quot;this&quot; {
  customer_gateway_id = aws_customer_gateway.this.id
  transit_gateway_id  = aws_ec2_transit_gateway.this.id
  type                = &quot;ipsec.1&quot;
  static_routes_only  = true
}&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;AWS Console에서 생성하는 옵션을 살펴보면 아래와같다.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-origin-width=&quot;1047&quot; data-origin-height=&quot;728&quot; data-ke-mobilestyle=&quot;widthOrigin&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/TDPPB/btrbVobuFaD/xD1yhsFv6jtIq8RHaAHbU0/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/TDPPB/btrbVobuFaD/xD1yhsFv6jtIq8RHaAHbU0/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/TDPPB/btrbVobuFaD/xD1yhsFv6jtIq8RHaAHbU0/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FTDPPB%2FbtrbVobuFaD%2FxD1yhsFv6jtIq8RHaAHbU0%2Fimg.png&quot; data-origin-width=&quot;1047&quot; data-origin-height=&quot;728&quot; data-ke-mobilestyle=&quot;widthOrigin&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;h2 data-ke-size=&quot;size26&quot;&gt;단계2: AWS Site-To-Site VPN 설정 확인&lt;/h2&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;AWS Console &amp;gt; Site-To-Site VPN Connections 화면을 살펴보면 새로운 VPN이 생성된 것을 확인 할 수 있다. 방금 생성한 VPN을 선택하고 Download Configuration을 눌러서 설정을 내려받도록한다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&quot;imageblock alignCenter&quot; data-origin-width=&quot;969&quot; data-origin-height=&quot;354&quot; data-ke-mobilestyle=&quot;widthOrigin&quot;&gt;&lt;span data-url=&quot;https://blog.kakaocdn.net/dn/b1vHNg/btrbV1f4cDl/J9xbLyaRdIeehVbDoZ3fSk/img.png&quot; data-phocus=&quot;https://blog.kakaocdn.net/dn/b1vHNg/btrbV1f4cDl/J9xbLyaRdIeehVbDoZ3fSk/img.png&quot;&gt;&lt;img src=&quot;https://blog.kakaocdn.net/dn/b1vHNg/btrbV1f4cDl/J9xbLyaRdIeehVbDoZ3fSk/img.png&quot; srcset=&quot;https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&amp;fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fb1vHNg%2FbtrbV1f4cDl%2FJ9xbLyaRdIeehVbDoZ3fSk%2Fimg.png&quot; data-origin-width=&quot;969&quot; data-origin-height=&quot;354&quot; data-ke-mobilestyle=&quot;widthOrigin&quot; onerror=&quot;this.onerror=null; this.src='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png'; this.srcset='//t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png';&quot;/&gt;&lt;/span&gt;&lt;/figure&gt;
&lt;/p&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;vpn-xxxxxxxxxxxx.txt 파일을 확인 할 수 있는데, 이 파일에는 2개의 터널 설정 정보가 담겨있다. 여기서는 터널 1개만 올릴 예정이므로 IPSec Tunnel #1를 사용하도록 한다. 다음 항목들을 메모하도록하자.&lt;/p&gt;
&lt;ul style=&quot;list-style-type: disc;&quot; data-ke-list-type=&quot;disc&quot;&gt;
&lt;li&gt;Pre-Shared Key (AWS에서 생성된 값)&lt;/li&gt;
&lt;li&gt;Customer Gateway (온프렘 VPC Openswan의 Public IP, 여기서는 EIP)&lt;/li&gt;
&lt;li&gt;Virtual Private Gateway (AWS에서 생성된 VPN 터널의 Public IP)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre id=&quot;code_1628732370367&quot; class=&quot;shell&quot; data-ke-language=&quot;shell&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;IPSec Tunnel #1
================================================================================
#1: Internet Key Exchange Configuration
		
Configure the IKE SA as follows:
Please note, these sample configurations are for the minimum requirement of AES128, SHA1, and DH Group 2.
Category &quot;VPN&quot; connections in the GovCloud region have a minimum requirement of AES128, SHA2, and DH Group 14.
You will need to modify these sample configuration files to take advantage of AES256, SHA256, or other DH groups like 2, 14-18, 22, 23, and 24.
NOTE: If you customized tunnel options when creating or modifying your VPN connection, you may need to modify these sample configurations to match the custom settings for your tunnels.

Higher parameters are only available for VPNs of category &quot;VPN,&quot; and not for &quot;VPN-Classic&quot;.
The address of the external interface for your customer gateway must be a static address.
Your customer gateway may reside behind a device performing network address translation (NAT).
To ensure that NAT traversal (NAT-T) can function, you must adjust your firewall !rules to unblock UDP port 4500. 
| If not behind NAT, and you are not using an Accelerated VPN, we recommend disabling NAT-T. If you are using an Accelerated VPN, make sure that NAT-T is enabled.
  - IKE version              : IKEv1 
  - Authentication Method    : Pre-Shared Key 
  - Pre-Shared Key           : UdRFA9AbvcSXfcjIuWiIggrSQfhvJ9oJ
  - Authentication Algorithm : sha1
  - Encryption Algorithm     : aes-128-cbc
  - Lifetime                 : 28800 seconds
  - Phase 1 Negotiation Mode : main
  - Diffie-Hellman           : Group 2

#2: IPSec Configuration

Configure the IPSec SA as follows:
Category &quot;VPN&quot; connections in the GovCloud region have a minimum requirement of AES128, SHA2, and DH Group 14.
Please note, you may use these additionally supported IPSec parameters for encryption like AES256 and other DH groups like 2, 5, 14-18, 22, 23, and 24.
NOTE: If you customized tunnel options when creating or modifying your VPN connection, you may need to modify these sample configurations to match the custom settings for your tunnels.

Higher parameters are only available for VPNs of category &quot;VPN,&quot; and not for &quot;VPN-Classic&quot;.
  - Protocol                 : esp
  - Authentication Algorithm : hmac-sha1-96
  - Encryption Algorithm     : aes-128-cbc
  - Lifetime                 : 3600 seconds
  - Mode                     : tunnel
  - Perfect Forward Secrecy  : Diffie-Hellman Group 2
	
IPSec Dead Peer Detection (DPD) will be enabled on the AWS Endpoint. We
recommend configuring DPD on your endpoint as follows:
  - DPD Interval             : 10
  - DPD Retries              : 3

IPSec ESP (Encapsulating Security Payload) inserts additional
headers to transmit packets. These headers require additional space, 
which reduces the amount of space available to transmit application data.
To limit the impact of this behavior, we recommend the following 
configuration on your Customer Gateway:
  - TCP MSS Adjustment       : 1379 bytes
  - Clear Don't Fragment Bit : enabled
  - Fragmentation            : Before encryption

#3: Tunnel Interface Configuration

Your Customer Gateway must be configured with a tunnel interface that is
associated with the IPSec tunnel. All traffic transmitted to the tunnel
interface is encrypted and transmitted to the Virtual Private Gateway.



The Customer Gateway and Virtual Private Gateway each have two addresses that relate
to this IPSec tunnel. Each contains an outside address, upon which encrypted
traffic is exchanged. Each also contain an inside address associated with
the tunnel interface.
 
The Customer Gateway outside IP address was provided when the Customer Gateway
was created. Changing the IP address requires the creation of a new
Customer Gateway.

The Customer Gateway inside IP address should be configured on your tunnel
interface. 

Outside IP Addresses:
  - Customer Gateway 		        : 13.125.83.100
  - Virtual Private Gateway	        : 3.34.244.100
		
Inside IP Addresses
  - Customer Gateway         		: 169.254.227.170/30
  - Virtual Private Gateway         : 169.254.227.169/30

Configure your tunnel to fragment at the optimal size:
  - Tunnel interface MTU     : 1436 bytes
    

#4: Static Routing Configuration:

To route traffic between your internal network and your VPC, 
you will need a static route added to your router.

Static Route Configuration Options:

  - Next hop       : 169.254.227.169
  
You should add static routes towards your internal network on the VGW.
The VGW will then send traffic towards your internal network over 
the tunnels.&lt;/code&gt;&lt;/pre&gt;
&lt;h3 data-ke-size=&quot;size23&quot;&gt;&lt;span style=&quot;font-family: AppleSDGothicNeo-Regular, 'Malgun Gothic', '맑은 고딕', dotum, 돋움, sans-serif;&quot;&gt;단계3: Openswan 설치&lt;/span&gt;&lt;/h3&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;설치 스크립트는 다음과 같다. 스크립트를 실행하면 /etc/ipsec.d/tunnel.conf, /etc/ipsec.d/tunnel.secrets 에 설정이 만들어진다.&lt;/p&gt;
&lt;pre id=&quot;code_1628732637800&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;#!/bin/bash

read -p &quot;Left IP(VPN IP): &quot; LEFT_IP
read -p &quot;Left CIDR(VPN CIDR): &quot; LEFT_CIDR
read -p &quot;Right IP(AWS IP): &quot; RIGHT_IP
read -p &quot;Right CIDR(AWS CIDR): &quot; RIGHT_CIDR
read -p &quot;VPN Secrets: &quot; SECRETS

echo

yum install -y openswan

cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/ipsec.d/tunnel.conf
conn tunnel1
        authby = secret
        auto = start
        left = %defaultroute
        leftid = $LEFT_IP
        right = $RIGHT_IP
        type = tunnel
        ikelifetime = 8h
        keylife = 1h
        phase2alg = aes128-sha1;modp1024
        ike = aes128-sha1;modp1024
        keyingtries = %forever
        keyexchange = ike
        leftsubnet = $LEFT_CIDR
        rightsubnet = $RIGHT_CIDR
        dpddelay = 10
        dpdtimeout = 30
        dpdaction = restart_by_peer
EOF


cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/ipsec.d/tunnel.secrets
$LEFT_IP $RIGHT_IP: PSK &quot;$SECRETS&quot;
EOF

cat &amp;lt;&amp;lt;EOF &amp;gt; /etc/sysctl.d/99-vpn.conf
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.accept_source_route = 0
EOF

sysctl --system

service ipsec restart
sleep 5
ipsec status&lt;/code&gt;&lt;/pre&gt;
&lt;h2 data-ke-size=&quot;size26&quot;&gt;단계4: Openswan 연결 확인&lt;/h2&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;아래와 같이 나온다면, VPN이 정상적으로 연결된 것이다.&lt;/p&gt;
&lt;pre id=&quot;code_1628732709880&quot; class=&quot;shell&quot; data-ke-language=&quot;shell&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;$ ipsec status
000 Connection list:
000
000 &quot;tunnel1&quot;: 10.100.0.0/16===10.100.0.238[13.125.83.100]---10.100.0.1...3.34.244.105&amp;lt;3.34.244.100&amp;gt;===10.0.0.0/16; erouted; eroute owner: #2
000 &quot;tunnel1&quot;:     oriented; my_ip=unset; their_ip=unset; my_updown=ipsec _updown;
000 &quot;tunnel1&quot;:   xauth us:none, xauth them:none,  my_username=[any]; their_username=[any]
000 &quot;tunnel1&quot;:   our auth:secret, their auth:secret
000 &quot;tunnel1&quot;:   modecfg info: us:none, them:none, modecfg policy:push, dns:unset, domains:unset, banner:unset, cat:unset;
000 &quot;tunnel1&quot;:   labeled_ipsec:no;
000 &quot;tunnel1&quot;:   policy_label:unset;
000 &quot;tunnel1&quot;:   ike_life: 28800s; ipsec_life: 3600s; replay_window: 32; rekey_margin: 540s; rekey_fuzz: 100%; keyingtries: 0;
000 &quot;tunnel1&quot;:   retransmit-interval: 500ms; retransmit-timeout: 60s;
000 &quot;tunnel1&quot;:   initial-contact:no; cisco-unity:no; fake-strongswan:no; send-vendorid:no; send-no-esp-tfc:no;
000 &quot;tunnel1&quot;:   policy: PSK+ENCRYPT+TUNNEL+PFS+UP+IKEV1_ALLOW+IKEV2_ALLOW+SAREF_TRACK+IKE_FRAG_ALLOW+ESN_NO;
000 &quot;tunnel1&quot;:   conn_prio: 16,16; interface: eth0; metric: 0; mtu: unset; sa_prio:auto; sa_tfc:none;
000 &quot;tunnel1&quot;:   nflog-group: unset; mark: unset; vti-iface:unset; vti-routing:no; vti-shared:no; nic-offload:auto;
000 &quot;tunnel1&quot;:   our idtype: ID_IPV4_ADDR; our id=13.125.83.131; their idtype: ID_IPV4_ADDR; their id=3.34.244.105
000 &quot;tunnel1&quot;:   dpd: action:restart; delay:10; timeout:30; nat-t: encaps:auto; nat_keepalive:yes; ikev1_natt:both
000 &quot;tunnel1&quot;:   newest ISAKMP SA: #1; newest IPsec SA: #2;
000 &quot;tunnel1&quot;:   IKE algorithms: AES_CBC_128-HMAC_SHA1-MODP1024
000 &quot;tunnel1&quot;:   IKE algorithm newest: AES_CBC_128-HMAC_SHA1-MODP1024
000 &quot;tunnel1&quot;:   ESP algorithms: AES_CBC_128-HMAC_SHA1_96-MODP1024
000 &quot;tunnel1&quot;:   ESP algorithm newest: AES_CBC_128-HMAC_SHA1_96; pfsgroup=MODP1024
000
000 Total IPsec connections: loaded 1, active 1
000
000 State Information: DDoS cookies not required, Accepting new IKE connections
000 IKE SAs: total(1), half-open(0), open(0), authenticated(1), anonymous(0)
000 IPsec SAs: total(1), authenticated(1), anonymous(0)
000
000 #1: &quot;tunnel1&quot;:4500 STATE_MAIN_I4 (ISAKMP SA established); EVENT_SA_REPLACE in 26379s; newest ISAKMP; lastdpd=7s(seq in:15226 out:0); idle; import:admin initiate
000 #2: &quot;tunnel1&quot;:4500 STATE_QUICK_I2 (sent QI2, IPsec SA established); EVENT_SA_REPLACE in 1420s; newest IPSEC; eroute owner; isakmp#1; idle; import:admin initiate
000 #2: &quot;tunnel1&quot; esp.c62044bb@3.34.244.100 esp.bede1846@10.100.0.238 tun.0@3.34.244.100 tun.0@10.100.0.238 ref=0 refhim=0 Traffic: ESPin=0B ESPout=0B! ESPmax=4194303B
000
000 Bare Shunt list:
000&lt;/code&gt;&lt;/pre&gt;
&lt;p data-ke-size=&quot;size16&quot;&gt;&amp;nbsp;&lt;/p&gt;</description>
      <category>AWS</category>
      <category>AWS</category>
      <category>Openswan</category>
      <category>VPN</category>
      <author>구리z</author>
      <guid isPermaLink="true">https://dgoh.tistory.com/129</guid>
      <comments>https://dgoh.tistory.com/129#entry129comment</comments>
      <pubDate>Thu, 12 Aug 2021 10:48:54 +0900</pubDate>
    </item>
    <item>
      <title>[Ubuntu20] Unattended upgrade 비활성화</title>
      <link>https://dgoh.tistory.com/128</link>
      <description>&lt;h2 data-ke-size=&quot;size26&quot;&gt;개요&lt;/h2&gt;
&lt;p&gt;Ubuntu에는 보안상 자동으로 패키지를 업그레이드 해주는 타이머가 설정돼있다. 그러나 서버 운영 중 자동으로 패키지 업그레이드가 발생되면 서비스에 영향을 끼칠 수 있어서 비활성화해주는 것이 좋다. 크게 두 가지 작업을 해야한다.&lt;/p&gt;
&lt;h2 data-ke-size=&quot;size26&quot;&gt;작업1. apt 서비스&amp;amp;타이머 비활성화&lt;/h2&gt;
&lt;pre id=&quot;code_1613646558545&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;# 활성화 여부를 체크한다.
$ systemctl list-timers | grep apt-daily
Thu 2021-02-18 23:54:33 UTC 12h left      Thu 2021-02-18 07:55:01 UTC 3h 15min ago apt-daily.timer              apt-daily.service
Fri 2021-02-19 06:47:28 UTC 19h left      Thu 2021-02-18 06:03:01 UTC 5h 7min ago  apt-daily-upgrade.timer      apt-daily-upgrade.service

# 관련 서비스와 타이머를 비활성화 중지한다.
$ systemctl stop apt-daily.timer
$ systemctl disable apt-daily.timer
$ systemctl disable apt-daily.service
$ systemctl stop apt-daily-upgrade.timer
$ systemctl disable apt-daily-upgrade.timer
$ systemctl disable apt-daily-upgrade.service&lt;/code&gt;&lt;/pre&gt;
&lt;h2 data-ke-size=&quot;size26&quot;&gt;작업2. apt config 변경&lt;/h2&gt;
&lt;pre id=&quot;code_1613647504400&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;# APT::Periodic::Update-Package-Lists을 &quot;0&quot;으로 설정한다.
$ cat /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists &quot;0&quot;;
APT::Periodic::Download-Upgradeable-Packages &quot;0&quot;;
APT::Periodic::AutocleanInterval &quot;0&quot;;
APT::Periodic::Unattended-Upgrade &quot;0&quot;;

# apt 설정 확인
$ apt-config dump | grep Update-Package-Lists
APT::Periodic::Update-Package-Lists &quot;0&quot;;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 data-ke-size=&quot;size26&quot;&gt;unattended-upgrade 실행여부 확인 방법&lt;/h2&gt;
&lt;h3 data-ke-size=&quot;size23&quot;&gt;unattended-upgrade가 활성화된 상황&lt;/h3&gt;
&lt;pre id=&quot;code_1613691329596&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;$ ls -al /var/log/unattended-upgrades/
total 12
drwxr-x---  2 root adm    4096 Feb 18 12:43 .
drwxrwxr-x 13 root syslog 4096 Feb 18 11:21 ..
-rw-r--r--  1 root root      0 Feb 18 11:39 unattended-upgrades-dpkg.log
-rw-r--r--  1 root root      0 Feb 18 02:44 unattended-upgrades-shutdown.log
-rw-r--r--  1 root root    798 Feb 18 16:18 unattended-upgrades.log&lt;/code&gt;&lt;/pre&gt;
&lt;h3 data-ke-size=&quot;size23&quot;&gt;unattended-upgrade가 비활성화된 상황&lt;/h3&gt;
&lt;pre id=&quot;code_1613691387298&quot; class=&quot;html xml&quot; data-ke-language=&quot;html&quot; data-ke-type=&quot;codeblock&quot;&gt;&lt;code&gt;$ ls -al /var/log/unattended-upgrades/
total 8
drwxr-x---  2 root adm    4096 Feb 18 12:43 .
drwxrwxr-x 13 root syslog 4096 Feb 18 11:21 ..
-rw-r--r--  1 root root      0 Feb 18 02:44 unattended-upgrades-shutdown.log&lt;/code&gt;&lt;/pre&gt;</description>
      <category>ubuntu</category>
      <author>구리z</author>
      <guid isPermaLink="true">https://dgoh.tistory.com/128</guid>
      <comments>https://dgoh.tistory.com/128#entry128comment</comments>
      <pubDate>Thu, 18 Feb 2021 20:25:35 +0900</pubDate>
    </item>
    <item>
      <title>SSH - ssh command 실행 시, 환경 변수 넘기기</title>
      <link>https://dgoh.tistory.com/127</link>
      <description>&lt;h1&gt;개요&lt;/h1&gt;&lt;div&gt;ssh를 이용해 원격으로 명령어를 실행 할 때, 환경 변수를 관리하고 설정하는 법을 설명한다.&lt;/div&gt;&lt;h1&gt;기본 설정&lt;/h1&gt;&lt;div&gt;기본 설정 값으로 넘길 수 있는 환경변수는 설정 파일에 아래와 같이 설정되어있다.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;주로 Locale 관련된 값이 넘어가는 것을 알 수 있다. 위 환경변수들은 ssh command를 실행 할 때 시스템에 설정된 값이 같이 넘어간다고 보면된다.&lt;/p&gt;&lt;h1&gt;추가하기&lt;/h1&gt;&lt;div&gt;ssh command에 사용 할 환경변수를 추가하려면 두 단계로 설정을 해야한다. A서버에서 B서버로 명령어를 실행한다고 가정한다.&lt;/div&gt;&lt;h2&gt;A서버 설정&lt;/h2&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;cat ~/.ssh/config &amp;lt;&amp;lt; SendEnv MY_ENV&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2&gt;B서버 설정&lt;/h2&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;cat /etc/ssh/sshd_config &amp;lt;&amp;lt; AcceptEnv MY_ENV&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1&gt;실행하기&lt;/h1&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;MY_ENV=hello ssh test.machine.ip -c &quot;echo $MY_ENV&quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <category>Linux</category>
      <category>ssh</category>
      <category>ssh command</category>
      <author>구리z</author>
      <guid isPermaLink="true">https://dgoh.tistory.com/127</guid>
      <comments>https://dgoh.tistory.com/127#entry127comment</comments>
      <pubDate>Thu, 17 May 2018 11:21:09 +0900</pubDate>
    </item>
    <item>
      <title>OpenVPN - TCP 사용 시 속도가 느릴 때</title>
      <link>https://dgoh.tistory.com/126</link>
      <description>&lt;h1&gt;개요&lt;/h1&gt;&lt;div&gt;OpenVPN 기본 설정을&amp;nbsp;사용해 TCP VPN 터널링(Site-To-Site) 구축 후, 파일전송을 해보면 속도가 지나치게 느린 경우가 생긴다. 자세한 설명은 &lt;a href=&quot;https://www.lowendtalk.com/discussion/40099/why-openvpn-is-so-slow-cool-story&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;이 블로그&lt;/a&gt;를 참고하면 된다. 요약하면 windows size가 너무 작아 이 부분 설정이 필요하다.&lt;/div&gt;&lt;h1&gt;설정 1. window size 조절&lt;/h1&gt;&lt;div&gt;서버와 클라이언트 양 쪽에 해당 설정을 추가하고 연결을 맺는다. 클라이언트 설정을 강제하지 않으려면 push로 시작하는 설정을 삭제해도된다.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;sndbuf 0
rcvbuf 0
push &quot;sndbuf 393216&quot;
push &quot;rcvbuf 393216&quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1&gt;설정 2. comp-lzo 삭제&lt;/h1&gt;&lt;div&gt;comp-lzo가 설정 돼있으면 CPU 사용량이 늘어나면서 속도가 느려질 수 있으니 속도 향상을 위해서는 비활성화 하도록 하자.&lt;/div&gt;&lt;h1&gt;설정 3. socket-flags TCP_NODELAY&lt;/h1&gt;&lt;div&gt;&lt;a href=&quot;https://openvpn.net/index.php/open-source/documentation/manuals/69-openvpn-21.html&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;OpenVPN 설정 문서&lt;/a&gt;에 보면 TCP 환경 구성시 성능 향상을 위해 추천한다고 적혀있다.&lt;/div&gt;&lt;h1&gt;결과&lt;/h1&gt;&lt;div&gt;테스트 결과, 설정 전에&amp;nbsp;초당 2~3메가 정도 전송속도가 나왔는데 초당 20~30메가 정도로 눈에 띄는 속도 향상이 있었다.&lt;/div&gt;&lt;h1&gt;참고&lt;/h1&gt;&lt;p&gt;https://community.openvpn.net/openvpn/wiki/Gigabit_Networks_Linux&lt;/p&gt;
&lt;p&gt;https://hamy.io/post/0003/optimizing-openvpn-throughput/&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Linux</category>
      <category>openvpn</category>
      <category>tcp</category>
      <category>window size</category>
      <author>구리z</author>
      <guid isPermaLink="true">https://dgoh.tistory.com/126</guid>
      <comments>https://dgoh.tistory.com/126#entry126comment</comments>
      <pubDate>Mon, 12 Mar 2018 18:05:05 +0900</pubDate>
    </item>
    <item>
      <title>telnet 없이 포트 오픈 여부 점검하기</title>
      <link>https://dgoh.tistory.com/125</link>
      <description>&lt;h1&gt;개요&lt;/h1&gt;&lt;div&gt;대부분의 서버의 경우 telnet이 설치되어 있겠지만, 보안상 인터넷망도 연결되어있지 않고 telnet도 설치가 안되어있는데 포트 점검을 하고 싶은 경우가 생긴다. 아무리 최소 설치를 하더라도 curl을 설치가 되어있다.&lt;/div&gt;&lt;h1&gt;해결방법&lt;/h1&gt;&lt;div&gt;curl의 파라메터 중 url에 telnet 스키마도 허용이된다.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;bash&quot;&gt;$ curl -v telnet://ip:port&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Linux</category>
      <category>curl</category>
      <category>port</category>
      <author>구리z</author>
      <guid isPermaLink="true">https://dgoh.tistory.com/125</guid>
      <comments>https://dgoh.tistory.com/125#entry125comment</comments>
      <pubDate>Thu, 1 Feb 2018 15:46:35 +0900</pubDate>
    </item>
    <item>
      <title>Docker - docker: Error response from daemon: No command specified</title>
      <link>https://dgoh.tistory.com/124</link>
      <description>&lt;h1&gt;개요&lt;/h1&gt;&lt;div&gt;Docker 이미지를 옮길 때 나는 에러이다. Docker image를 추출하고 저장하는 것처럼 보이는 명령어가 몇 가지 있는데 헷갈리면 안된다.&lt;/div&gt;&lt;h1&gt;export, import&lt;/h1&gt;&lt;div&gt;이미지가 아니라 컨테이너 데이터를 옮길 때 사용하는 명령어이다.&lt;/div&gt;&lt;h1&gt;save, load&lt;/h1&gt;&lt;div&gt;이미지를 추출하고 옮기는 명령어이다. 제목에 있는 에러는 save로 저장하고 import로 올렸을 때 나는 에러이다.&lt;/div&gt;&lt;h1&gt;결론&lt;/h1&gt;&lt;div&gt;docker: Error response from daemon: No command specified 이 에러가 날 떄는 save, load 명령어를 잘 쓰고 있는지 확인해야한다.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>DevOps</category>
      <category>DevOps</category>
      <category>docker</category>
      <author>구리z</author>
      <guid isPermaLink="true">https://dgoh.tistory.com/124</guid>
      <comments>https://dgoh.tistory.com/124#entry124comment</comments>
      <pubDate>Thu, 30 Nov 2017 18:42:05 +0900</pubDate>
    </item>
    <item>
      <title>리눅스 - 간단하게 방화벽 점검하기 (간단한 포트 오픈)</title>
      <link>https://dgoh.tistory.com/123</link>
      <description>&lt;h1&gt;머리글&lt;/h1&gt;&lt;div&gt;클라우드에서 인스턴스를 실행하고 방화벽 설정을 하고나면 제대로 설정이 되었나 테스트를 해보고 싶다. 이럴 때 아무 포트나 오픈해서 telnet으로 체크를 하는 것이 간단한 방법이라 생각된다. 보통 아무 포트는 22번같은 포트를 체크하곤 했었는데 TCP/UDP로 특정 포트를 간단하게 Listening하게 해주는 유틸리티를 발견했다.&lt;/div&gt;&lt;h1&gt;해결책&lt;/h1&gt;&lt;div&gt;nc 라는 &lt;a href=&quot;http://www.tutorialspoint.com/unix_commands/nc.htm&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;UNIX/Linux command utility&lt;/a&gt;를 사용하면된다.&amp;nbsp;&lt;/div&gt;&lt;div&gt;포트를 오픈 할 머신에 &lt;span style=&quot;background-color: rgb(234, 234, 234);&quot;&gt;nc -l 10000&lt;/span&gt;을 실행하고,&amp;nbsp; 접속 할 머신에서 &lt;span style=&quot;background-color: rgb(234, 234, 234);&quot;&gt;telnet {target} 10000&lt;/span&gt;으로 오픈이 되는지 확인한다.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Linux</category>
      <category>NC</category>
      <category>port</category>
      <category>리눅스</category>
      <category>방화벽체크</category>
      <author>구리z</author>
      <guid isPermaLink="true">https://dgoh.tistory.com/123</guid>
      <comments>https://dgoh.tistory.com/123#entry123comment</comments>
      <pubDate>Wed, 15 Nov 2017 15:37:48 +0900</pubDate>
    </item>
    <item>
      <title>Docker - Container에서 Host로 접속 (Mac)</title>
      <link>https://dgoh.tistory.com/122</link>
      <description>&lt;h1&gt;머리글&lt;/h1&gt;&lt;div&gt;Docker로 이것저것 작업을 하다보면 Container에서 호스트로 접속 할 일이 생긴다. 모든 Container를 --net=host로 띄우면 되지만 네트워크를 분리하고 싶을 경우 이건 해결책으로 사용 할 수가 없다. 두 가지 방법이 있다.&lt;/div&gt;&lt;h1&gt;해결책1. network alias&lt;/h1&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;“shell”&quot;&gt;$ ifconfig lo0 -alias 1.1.1.1/24&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;1.1.1.1 이 Docker Container 안에서 사용될 아이피다. 시스템 내에서 사용하지 않는 아이피를 설정해서 사용하면 된다.&lt;/div&gt;&lt;h1&gt;해결책2. docker.for.mac.localhost&lt;/h1&gt;&lt;div&gt;Docker CE 17.06부터 추가된 hostname이다. Docker Container안에서 docker.for.mac.localhost를 호스트로 사용하면 바로 접근이된다.&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>DevOps</category>
      <category>docker</category>
      <category>docker container</category>
      <category>mac</category>
      <author>구리z</author>
      <guid isPermaLink="true">https://dgoh.tistory.com/122</guid>
      <comments>https://dgoh.tistory.com/122#entry122comment</comments>
      <pubDate>Mon, 13 Nov 2017 14:19:16 +0900</pubDate>
    </item>
    <item>
      <title>Docker - v1 registry 접속 실패 404 Not Found (disable-legacy-registry)</title>
      <link>https://dgoh.tistory.com/121</link>
      <description>&lt;h1&gt;머리글&lt;/h1&gt;&lt;div&gt;docker-ce 17.06 버전부터 Registry V1과 통신이이 기본으로 막혀있다. deprecated 예정이지만 꼭 사용해야 하는 시스템이 있으면 이 옵션을 강제로 활성화 시킬 수 있다. 이 글에서 Docker Registry 주소를 http://127.0.0.1:5000 이라고 가정하겠다.&lt;/div&gt;&lt;h1&gt;문제점&lt;/h1&gt;&lt;div&gt;이 문제가 발생하면 아래처럼 기본적으로 404 Not Found 에러가난다. 에러메시지가 좀 더 도움이 되면 좋겠지만 그렇지않다.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;Error response from daemon: login attempt to http://127.0.0.1:5000/v2/ failed with status: 404 Not Found&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;Docker API Version v1.12.0부터 기본으로 V1 사용이 비활성화되었는데, 이 버전은 Docker 버전과 다르다. docker version 명령어로 관련된 정보를 모두 확인 할 수 있다.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;$ docker version
Client:
 Version:      17.03.2-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   f5ec1e2
 Built:        Tue Jun 27 03:11:13 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.2-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   f5ec1e2
 Built:        Tue Jun 27 03:11:13 2017
 OS/Arch:      linux/amd64
 Experimental: false&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1&gt;방법1&lt;/h1&gt;&lt;div&gt;사실 &lt;a href=&quot;https://docs.docker.com/engine/deprecated/#interacting-with-v1-registries&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;공식홈페이지 문서&lt;/a&gt;에도 잘 나와있지만 매번 찾는게 생각보다 어려워서 블로그에 옮겨적는다. docker pull/push/login 명령어에 &lt;span style=&quot;background-color: rgb(246, 246, 246);&quot;&gt;--disable-legacy-registry=false&lt;/span&gt;를 옵션으로 넣고 실행하면된다.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;$ docker login 127.0.0.1:5000 --disable-legacy-registry=false&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1&gt;방법2&lt;/h1&gt;&lt;div&gt;방법1로 하면 매번 옵션을 추가해줘야하는 불편함이 있다. 아예 docker 데몬이 실행 될 때 설정에 추가하는 법도 있다.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;json&quot;&gt;{
  &quot;disable-legacy-registry&quot;:false
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>DevOps</category>
      <category>disable legacy registry</category>
      <category>docker</category>
      <category>docker registry</category>
      <author>구리z</author>
      <guid isPermaLink="true">https://dgoh.tistory.com/121</guid>
      <comments>https://dgoh.tistory.com/121#entry121comment</comments>
      <pubDate>Mon, 25 Sep 2017 16:32:30 +0900</pubDate>
    </item>
    <item>
      <title>Python - HTTP Digest Authentication 서버, 클라이언트 구축 (HTTPDigestAuthHandler)</title>
      <link>https://dgoh.tistory.com/120</link>
      <description>&lt;h1&gt;머리글&lt;/h1&gt;&lt;div&gt;HTTP 서비스를 구축 할 때, 외부에 공개되지 않도록 하기위해 인증 시스템을 도입하는 경우를 생각해보자. HTTP 프로토콜에서 기본으로 제공하는 인증 시스템이 있는데 가장 간단한 방법은 &lt;a href=&quot;http://www.rfc-editor.org/info/rfc7617&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;Basic Authentication&lt;/a&gt;이다. 이 방법은 아이디/암호를 통해 인증을 하도록 되어있는데, 만약 TLS(HTTPS) 설정이 되어있지 않다면 plain text가 노출 돼 스니핑을 당해서 아이디/암호가 노출 됐을 때, 다른 시스템까지 보안에 취약해 질 수 있어서 위험하다. 모든 서버에 TLS를 설정하면 된다고는 하지만 속도나 비용문제 등을 생각 했을 때 항상 옳은 법은 아니다. 그래서 &lt;a href=&quot;https://tools.ietf.org/html/rfc7616&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;HTTP Digest Authentication&lt;/a&gt;이란 인증 방법을 사용해보려고 한다.&lt;/div&gt;&lt;h1&gt;설명&lt;/h1&gt;&lt;div&gt;HTTP Digest Authentication의 자세한 설명은 다른 아티클에 있으니 아주 간단한게 설명하고 코드 위주로 정리 할 것이다.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;1. 클라이언트가 서버에 접근 요청을 하면 Basic Authentication과 같이 401을 보냄. 이 때 헤더에 인증이나 필요한 암호화 알고리즘과 키 값을 포함해서 보냄.&lt;/div&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;2 클라이언트에서는 아이디와 암호를 서버에서 받은 키 값과 암호화 알고리즘을 이용하여 인증 요청&lt;/div&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;3. 서버에서 설정된 값이 맞는지 확인&lt;/div&gt;&lt;div style=&quot;margin-left: 2em;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;간단하게 말하면 인증 요청 시, 서버에서 임시 키 값을 발급하고 클라이언트에서는 그 키 값을 조합해 암호화 된 값을 전송함으로써 plain text가 노출되어도 replay attack까지도 방지가 된다는 의미이다.&lt;/div&gt;&lt;h1&gt;서버 구현 with NGINX&lt;/h1&gt;&lt;div&gt;&amp;nbsp;가장 많이 사용하는 웹 서버 엔진으로 apache2와 nginx를 들 수 있는데, 이 중 nginx를 이용해 구축하도록 할 것이다. 아직 &lt;a href=&quot;https://www.nginx.com/resources/wiki/modules/auth_digest/&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;HTTP Digest Authentication&lt;/a&gt; 모듈은 NGINX에 공식적으로 들어가있지 않으며 &lt;a href=&quot;https://github.com/samizdatco/nginx-http-auth-digest&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;github repository&lt;/a&gt;에서 직접 다운 받아 설치해야한다. 기본 패키지에 포함되어있지 않아 nginx를 아래처럼 소스컴파일을 해야한다.&lt;/div&gt;&lt;h1&gt;1) NGINX 설치&lt;/h1&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;cd /usr/local/src
wget http://nginx.org/download/nginx-1.12.1.tar.gz
tar zxf nginx-1.12.1.tar.gz
git clone https://github.com/samizdatco/nginx-http-auth-digest.git
cp nginx-http-auth-digest/htdigest.py ~/htdigest.py
cd nginx-1.12.1
./configure --add-module=/usr/local/src/nginx-http-auth-digest
make &amp;amp;&amp;amp; make install&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1&gt;2) 암호 생성&lt;/h1&gt;&lt;div&gt;위 명령어 중 htdigest.py를 복사하는 걸 볼 수 있는데, 아이디와 암호를 생성해 파일로 만들어주는 유틸리티다. 생성을 위해서는 아이디, 암호, Realm이 필요하다. 여기서 입력하는 모든 정보는 다음 과정에서 설정 할 nginx.conf과 일치해야한다. 여기서 아이디는 guri, 암호는 1234, realm은 Guri Blog라고 입력하겠다.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;shell&quot;&gt;$ python htdigest.py passwd guri 'Guri Blog'
/home/guri/git-repo/docker-nginx-with-vts/passwd does not exist. Create it? (y/n) y
Password for new user &quot;guri&quot;:
Please repeat the password:
$ cat passwd
guri:Guri Blog:0247e8108bda8bd62baf454d636410b6&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1&gt;3) nginx.conf&lt;/h1&gt;&lt;div&gt;127.0.0.1:3000 HTTP 서버 Reverse Proxy와 같이 설정한다고 가정하겠다. 설정에 필요한 것만 최소로 남기면 아래와 같다.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;nginx&quot;&gt;worker_processes 4;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;
    gzip  on;

    server {
        listen       80;
        server_name  localhost;

        auth_digest_user_file /usr/local/etc/nginx/passwd;
        auth_digest_shm_size 4m;

        location / {
                auth_digest 'Guri Blog';
                auth_digest_timeout 60s; # 인증 정보를 받기전까지 기다리는 시간
                auth_digest_expires 10s; # 인증 후 또는 재사용 가능한 간격 시간
                auth_digest_replays 20; # 재사용 가능 횟수
                auth_digest_maxtries 5; # Status code가 200이 아닐 시 최대 시도 횟수
                auth_digest_evasion_time 300s; # auth_digest_maxtries가 넘었을 때 서버에서 Deny 하는 시간

                proxy_pass http://127.0.0.1:3000;
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1&gt;클라이언트 구현 with Python&lt;/h1&gt;&lt;div&gt;&lt;a href=&quot;https://docs.python.org/2/library/urllib2.html#httpdigestauthhandler-objects&quot; target=&quot;_blank&quot; class=&quot;tx-link&quot;&gt;urllib2.HTTPDigestAuthHandler&lt;/a&gt;를 사용 할 것인데 사실 코드가 너무 간단해서 구현이라고 볼 것도 없다.&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;python&quot;&gt;import urllib2


def main():
    passwd_manager = urllib2.HTTPPasswordMgr()
    passwd_manager.add_password('Guri Blog', 'http://127.0.0.1/', 'guri', '1234')

    digest_auth_handler = urllib2.HTTPDigestAuthHandler(passwd_manager)

    opener = urllib2.build_opener(digest_auth_handler)
    urllib2.install_opener(opener)

    try:
        res = urllib2.urlopen('http://127.0.0.1/')
        print res.read()
    except urllib2.HTTPError as e:
        print e


if __name__ == '__main__':
    main()
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;HTTPPasswordMgr를 사용하기 싫으면 HTTPDigestAuthHandler에 바로 아래와 같이 설정해 줄 수도 있다&lt;/div&gt;&lt;div&gt;&lt;pre&gt;&lt;code class=&quot;python&quot;&gt;digest_auth_handler.add_password(realm='Guri Blog', uri='http://127.0.0.1/', user='guri', passwd='1234')&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h1&gt;확인&lt;/h1&gt;&lt;div&gt;이제 127.0.0.1:3000에 HTTP서버를 띄어놓고 테스트를 해보자.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</description>
      <category>Python</category>
      <category>http digest auth</category>
      <category>HTTPDigestAuthHandler</category>
      <category>HTTPPasswordMgr</category>
      <category>nginx</category>
      <category>Python</category>
      <author>구리z</author>
      <guid isPermaLink="true">https://dgoh.tistory.com/120</guid>
      <comments>https://dgoh.tistory.com/120#entry120comment</comments>
      <pubDate>Wed, 20 Sep 2017 10:57:04 +0900</pubDate>
    </item>
  </channel>
</rss>