💡 핵심 요약 (Executive Summary)
본 가이드는 cm curl 핵심 가이드 및 실전 아키텍처의 핵심 개념, 실전 구성 명령어 및 아키텍처 베스트 프랙티스를 다룹니다. 클라우드 네이티브 및 인프라 엔지니어링 실무에 즉시 활용 가능하도록 체계적으로 정리했습니다.
📑 Table of Contents
Exec
bash
#curl test
curl -sSL -o /dev/null -D - ${URL}
#download 받기(wget)
curl -LO ${URL}
curl -L ${URL} -o ${FILENAME}
#response Header 포함 출력
curl -i
#user 인증정보 포함
curl -u id:pw https://{ URL }
#X509 인증 무시
curl -k https:{ URL }
#verbose
curl -v { url }
#cacert cert key
curl --cacert *.pem --key *.pem --cert *.pem {{ url }}
#jq(json to pretty)
curl {url} | jq ''
#request Header
curl -H"Name: Value"
curl --header "Name: Value"
#request body
curl -d"{}"
curl --data "{}"
header
bash
-H "Authorization: bearer ${token}"
-H "Authorization: basic $(echo "${username}:${password}" | base64)"
-H "Content-Type: application/json" #페이로드의 데이터 타입
-H "Accept: application/json" #내가 리스폰스 받을 수 있는 타입
-H "Host: ${domain}" #ip로의 요청에 domain을 씌울 수 있음.
flags
bash
-L, --location
(HTTP) 서버가 요청한 페이지가 다른 위치로 이동했다고 보고하는 경우(Lo-
양이온: 헤더 및 3XX 응답 코드), 이 옵션을 사용하면 컬이 새 위치에서 요청을 다시 실행하게 됩니다. 만약에
-i, --include 또는 -I, --head와 함께 사용하면 요청된 모든 페이지의 헤더가 표시됩니다. 인증할 때‐
컬이 사용되면 컬은 자격 증명을 초기 호스트에만 보냅니다. 리디렉션으로 인해 컬이 다른 경우
호스트에서는 사용자+비밀번호를 가로챌 수 없습니다. 변경 방법에 대해서는 --location-trusted도 참조하세요.
이것. --max-redirs 옵션을 사용하여 따라야 할 리디렉션 양을 제한할 수 있습니다.
컬이 리디렉션을 따르고 요청이 POST인 경우 다음과 같은 요청을 GET과 함께 보냅니다.
HTTP 응답은 301, 302 또는 303입니다. 응답 코드가 다른 3xx 코드인 경우 컬은
수정되지 않은 동일한 방법을 사용하여 다음 요청을 수행합니다.
전용 옵션을 사용하여 30x 응답 후에 POST 요청을 GET으로 변경하지 않도록 컬에 지시할 수 있습니다.
즉, --post301, --post302 및 --post303입니다.
-X, --request로 설정된 메소드는 컬이 사용하기 위해 선택하는 메소드를 대체합니다.
예:
컬 -L https://example.com
--resolve 및 --alt-svc도 참조하세요.
Features
stdout 제거
bash
# 둘 다 동일함
curl $ep -o /dev/null
curl $ep 1>/dev/null
사설도메인, 사설 rootca인증서 /etc/hosts 등록 없이 https wget
bash
curl -LO https://${domain}/${path}/${upstream_file} \
--cacert ${cacert} \
--resolve ${domain}:443:${ip}
POST로 json file 전송
bash
vi ./test.json
curl -X POST https://wh.jandi.com/connect-api/webhook/20317820/626c58e4bc0497e2aa35492d01518385 \
-H "Accept: application/vnd.tosslab.jandi-v2+json" \ #리퀘스트바디 백엔드가 이해가능한 타입 명시
-H "Content-Type: application/json" \ #리스폰스 받을 요청타입 지정
--data @test.json # file
함수로 전송 (in the shell)
bash
#!/bin/bash
#ceph-df-print file export path
CEPH_DF_PRINT=/Enterprise Cloud_package/jandi/ceph-df-print
#function: read ceph-df-print file and display
generate_post_data() {
cat << EOF
{
"body": "[Ceph] 상태 조회 ($(date "+%Y-%m-%d %I:%M:%S %p"))",
"connectColor": "#FAC11B",
"connectInfo": [
{
"title": "Ceph HOST Status",
"description": "$(cat $CEPH_DF_PRINT | grep -e host -e root | awk 'NR==1 { print "NAME", "TOTAL", "AVAIL", "USAGE"} {gsub(/"/,""); print "["$19"-"$20"]",$4$5, $14$15,$8$9 "(" $16 "%)" }' | column -t -s' ' | awk '{printf "%s\\n", $0}')"
},
{
"title": "Ceph OSD Status",
"description": "$(cat $CEPH_DF_PRINT | grep osd | sort -r -k 17 | awk 'NR==1 { print "NAME", "TOTAL", "AVAIL", "USAGE"} {gsub(/"/,""); print "["$21"]", $5$6, $15$16, $9$10 "(" $17 "%)" }' | column -t -s' ' | awk '{printf "%s\\n", $0}')"
}
]
}
EOF
}
curl -X POST https://wh.jandi.com/connect-api/webhook/20317820/7e31d57c8d58bc28151e73926a371ad9 \
-H "Accept: application/vnd.tosslab.jandi-v2+json" \
-H "Content-Type: application/json" \
--data "$(generate_post_data)"
Leave a Reply