ThingWorx Flow > ThingWorx Flow 설치 및 관리 > ThingWorx Flow 관리 > ThingWorx Flow에 대한 외부 호출 만들기
ThingWorx Flow에 대한 외부 호출 만들기
다음 방법 중 하나를 사용하여 ThingWorx Flow에 대한 외부 호출을 만듭니다.
외부 웹 사이트에서 ThingWorx Flow로의 REST 호출 만들기
웹 사이트에서 ThingWorx Flow 서버에 대한 REST 호출을 만들려고 시도하면 해당 요청이 교차 원본 요청이므로 서버에서 이를 차단합니다. 이를 허용하려면 웹 사이트로부터의 교차 원본 요청을 허용하도록 ThingWorx Flow 서버를 구성해야 합니다. CORS(Cross-Origin Resource Sharing) 필터를 추가하여 ThingWorx Flow 서버에서 교차 원본 요청을 지원하도록 합니다. 그러면 다른 서버에 배포된 다른 웹 사이트에서 ThingWorx Flow 서버의 데이터에 액세스할 수 있습니다.
웹 사이트에서 ThingWorx Flow에 대한 REST 호출을 만들 수 있도록 하려면 다음 단계를 완료합니다.
1. 실행 중인 Nginx 인스턴스를 모두 종료합니다.
2. Nginx 설치의 다음 위치에 있는 vhost-flow.conf 파일을 엽니다.
Windows: C:/Program Files/nginx-<버전>/conf/conf.d
Linux: /etc/nginx/conf/conf.d
3. vhost-flow.conf 파일의 location /Thingworx 섹션에서 proxy_set_header X-Content-Type-Options nosniff; 줄을 찾은 후 다음 줄을 추가합니다.
set $cors '';
# Right side of condition can be regular expression:
# if ($http_origin ~ '^https?://(localhost|www\.yourdomain\.com|www\.yourotherdomain\.com)')
if ($http_origin = '<ThingWorx Flow를 호출하는 원본>') {
set $cors 'true';
}
if ($cors = 'true') {
add_header 'Access-Control-Allow-Origin' "$http_origin" always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
}
# OPTIONS indicates a CORS pre-flight request
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '$http_origin';
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range';
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
4. ThingWorx FoundationThingWorx Flow가 서로 다른 시스템에 설치되어 있는 경우 다음을 수행합니다.
vhost-flow.conf 파일에서 다음 줄을 찾습니다.
# add_header Content-Security-Policy
위의 줄 아래에 다음 줄을 추가합니다.
add_header Content-Security-Policy "frame-ancestors 'self' <ThingWorx Flow를 호출하는 원본>;";
도메인 이름을 하드 코딩하거나 RegEx를 제공할 수 있습니다. 예를 들면 다음과 같습니다. add_header Content-Security-Policy "frame-ancestors 'self' https://*.ptcnet.ptc.com;";
5. <ThingWorx Flow를 호출하는 원본>ThingWorx Flow에 액세스하려고 하는 웹 사이트의 URL로 바꿉니다.
6. Nginx 서비스를 다시 시작합니다.
ThingWorx Flow에 대한 WebSocket 호출 만들기
기본적으로 ThingWorx Flow에 대한 WebSocket 보안(wss) 호출을 만들 수 있습니다.
WebSocket(ws) 호출은 지원되지 않습니다.