[iPlanet] iPlanet7 CORS 설정
CORS 설정 전에 CORS에 간략히 설명하자면 아래와 같다.
CORS는 Corss-Origin Resource Sharing 으로 HTTP Header 기반의 메커니즘으로 브라우저가 Resource Road를 허용해야 하는 출처 이외의 모든 출처(도메인, 스키마 또는 포트)를 서버가 표시 할 수 있도록 하는 설정이다.
고객사에서 아래와 같이 3개의 도메인에 대해 CORS 설정을 요청하였다.
a.koreainvestment.com
b.koreainvestment.com
c.koreainvestment.com
1. CORS 설정 방법
${component-name}-obj.conf 파일에서 아래와 같은 내용을 추가한다.
<If defined $headers{'Origin'} and $headers{'Origin'} =~ '^(.*)\.(koreainvestment)\.com$'> Output fn="set-variable" insert-srvhdrs="Access-Control-Allow-Origin=$headers{'Origin'}" </If> |
이후 component를 shutdown 후 admin-console에서 deploy 후 component를 다시 running 하면 된다.
2. CORS 확인 방법
해당 설정이 iPlanet 단에서 정상적으로 동작하는지 확인 하는 방법으로는 아래와 같다.
oracle@uclick ~]$ curl http://localhost -H "Origin: https://a.koreainvestment.com" --verbose * About to connect() to localhost port 80 (#0) * Trying ::1... * Connection refused * Trying 127.0.0.1... * Connected to localhost (127.0.0.1) port 80 (#0) > GET / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: localhost > Accept: */* > Origin: https://a.koreainvestment.com > < HTTP/1.1 302 Moved Temporarily < Server: Oracle-iPlanet-Web-Server/7.0 < Date: Fri, 18 Nov 2022 00:31:09 GMT < Location: https://file.a.com/ < Content-length: 0 < * Connection #0 to host localhost left intact |
Header 부분에 설정 도메인이 정상적으로 나오는지 확인한다.
* 참고
https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
Cross-Origin Resource Sharing (CORS) - HTTP | MDN
Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any origins (domain, scheme, or port) other than its own from which a browser should permit loading resources. CORS also relies on a mechanism by which
developer.mozilla.org