예: REST API 구성
이 예에서는 네트워크 디바이스에서 REST API를 구성하는 Junos OS 방법을 보여주고 있습니다.
요구 사항
릴리스 14.2 이상에서 Junos OS 라우팅, 스위칭 또는 보안 디바이스가 필요합니다.
개요
이 예에서는 멀티 서비스 에지 라우터의 REST API를 주니퍼 네트웍스 M10i API를 구성합니다. 이 예에서는 lighttpd 및 Juise Tracing을 통해 HTTP 및 HTTPS 액세스를 구성합니다.
구성
CLI 빠른 구성
이 예제를 신속하게 구성하려면 다음 명령을 복사하고, 텍스트 파일에 붙여넣기하고, 라인 끊기를 제거하고, 네트워크 구성과 일치하는 데 필요한 세부 정보를 변경하고, 계층 수준에서 명령어를 복제하여 CLI, 구성 모드에서 [edit]
commit
입력합니다.
set system services rest control allowed-sources [192.0.2.0 198.51.100.0] set system services rest control connection-limit 100 set system services rest http port 3000 set system services rest http addresses [203.0.113.0 203.0.113.1] set system services rest https port 3443 set system services rest https addresses [203.0.113.2 203.0.113.3] set system services rest https server-certificate testcert set system services rest https cipher-list rsa-with-3des-ede-cbc-sha set system services rest https mutual-authentication certificate-authority testca set system services rest traceoptions flag all set system services rest enable-explorer
REST API 구성
단계별 절차
REST API를 구성하는 경우:
수신 HTTP 및 HTTPS 연결을 위해 허용된 IP 주소를 지정합니다.
[edit] user@R1# set system services rest control allowed-sources [192.0.2.0 198.51.100.0]
HTTP 및 HTTPS에서 허용되는 최대 연결 수를 지정합니다.
[edit] user@R1# set system services rest control connection-limit 100
수신 HTTP 연결을 위한 TCP 포트를 설정합니다.
[edit] user@R1# set system services rest http port 3000
수신 HTTP 연결을 위해 서버에서 수신되는 주소를 설정합니다.
[edit] user@R1# set system services rest http addresses [203.0.113.0 203.0.113.1]
수신 HTTPS 연결을 위한 TCP 포트를 설정합니다.
[edit] user@R1# set system services rest https port 3443
수신 HTTPS 연결을 위해 서버에서 수신되는 주소를 설정합니다.
[edit] user@R1# set system services rest https addresses [203.0.113.2 203.0.113.3]
서버 증명서를 설정합니다.
[edit] user@R1# set system services rest https server-certificate testcert
서버에서 암호화 및 복호화 기능을 수행하는 데 사용할 수 있는 암호 세트를 구성합니다.
[edit] user@R1# set system services rest https cipher-list rsa-with-3des-ede-cbc-sha
(선택 사항) 증명서가 있는 서버와 클라이언트 모두에서 TLS 상호 인증 설정
[edit] user@R1# set system services rest https mutual-authentication certificate-authority testca
(선택 사항) lighttpd, juise 또는 두 가지 모두에 대한 추적 옵션을 구성합니다.
[edit] user@R1# set system services rest traceoptions flag all
(선택 사항) REST API Explorer를 활성화합니다.
[edit] user@R1# set system services rest enable-explorer
구성을 커밋합니다.
[edit] user@R1# commit and-quit
결과
system { services { rest { control { allowed-sources [ 192.0.2.0 198.51.100.0 ]; connection-limit 100; } enable-explorer; http { addresses [ 203.0.113.0 203.0.113.1 ]; port 3000; } https { port 3443; addresses [ 203.0.113.2 203.0.113.3 ]; server-certificate testcert; cipher-list rsa-with-3des-ede-cbc-sha; mutual-authentication { certificate-authority testca; } } traceoptions { flag all; } } } }
확인
REST API 구성 검증
목적
REST API 구성이 디바이스에서 제대로 작동하고 있는지 확인합니다.
작업
운영 모드 명령을 실행하여 REST API 구성을 show configuration system services rest
표시합니다.
user@R1> show configuration system services rest http { port 3000; addresses [ 203.0.113.0 203.0.113.1 ]; } https { port 3443; addresses [ 203.0.113.2 203.0.113.3 ]; server-certificate testcert; cipher-list rsa-with-3des-ede-cbc-sha; mutual-authentication { certificate-authority testca; } } control { allowed-sources [ 192.0.2.0 198.51.100.0 ]; connection-limit 100; } traceoptions { flag all; } enable-explorer;
의미
이 예에서는 멀티 서비스 에지 라우터의 HTTP 및 HTTPS 주니퍼 네트웍스 M10i 구성했습니다. HTTP 액세스의 경우, 디바이스는 포트 3000을 수신하여 IP 주소 192.0.2.0, 198.51.100.0, 203.0.113.0 및 203.0.113.1의 트래픽을 허용합니다. 보다 안전한 연결을 위해 HTTPS 액세스는 포트 3443을 사용하여 상호 인증을 통해 구성되고 허용 IP 주소는 192.0.0.2.0, 198.51.100.0, 203.0.113.2 및 203.0.113.3입니다. HTTP와 HTTPS에 대해 100의 연결 제한이 구성되고 Juise 및 Lighttpd Tracing이 모두 활성화되어 있습니다. 기본적으로 REST API Explorer는 비활성화됩니다(예: REST API Explorer 사용).