Contents

System/OS
2020.09.04 05:59

Apache CORS 설정

Views 2710 Comment 1
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

CORS( Cross-origin resource sharing )은 XMLHttpRequest를 사용한 AJAX 호출을 Cross-Domain으로 가능하게 해준다. 

( Cross-Domain이 가능하다는 것은  [ www.A.com ]의 웹페이지에서 [ www.B.com ]의 resource를 사용할 수 있게 해준다는 것이다. )

특히 XMLHttpRequest는 request가 만들어진 도메인 내에서만 사용되도록 제한되어 왔지만,

현대에서는 점점 mash-up구조( 구글맵 연동이나, 여러가지 다른 open API를 연동) 에 대한 요구가 커지면서,

W3C는 CORS mechanism을 제안하였다. 

 

CORS를 지원하기 위해서 Cross Domain호출을 받아주는 서버( www.B.com )에서 이러한 호출방식을 받아주겠다는 설정을 해줘야 한다.   

 

- Apache CORS 설정

1. mod_headers 설정 :  Apache는 default가 enable이다. 

a2enmod headers

 

2. httpd.conf : <Directory>, <Location>, <Files>, <VirtualHost>안에 설정

       또는 .htaccess 안에 설정 가능

Header set Access-Control-Allow-Origin "*"

 

- Nginx

1. nginx.conf 설정

add_header Access-Control-Allow-Origin *;

 

# Cross-Domain 호출은 JSONP( JSON with Padding ) 을 사용할 수도 있으나,

JSONP는 get방식만 가능하다. 반면, CORS는 다른 HTTP Request방식도 지원이 된다.

그리고 CORS는 XMLHttpRequest를 사용 할 수 있으므로 error handling에 더 유리하다. 


[출처] https://sarc.io/index.php/httpd/261-apache-cors



?

List of Articles
No. Category Subject Author Date Views
46 System/OS [svn] Can't convert string from native encoding to 'UTF-8' 메시지가 나오는 경우 hooni 2014.12.18 993
45 System/OS iptime 공유기 해킹 기술문서 4 file hooni 2015.01.01 1941
44 System/OS [svn] 하나의 SVN에서 멀티 저장소 (One svnserve, multiple repositories) hooni 2015.01.02 1549
43 System/OS CentOS 에서 Cacti 설치하기 hooni 2015.01.02 1764
42 System/OS [linux] CentOS 에 APM 설치하기 hooni 2015.01.02 1690
41 System/OS [mac] Mac OS 패키지 매니저, HomeBrew file hooni 2015.01.03 1311
40 System/OS [mac] 패키지 매니저, MacPort hooni 2015.01.03 971
39 System/OS [mac] OS X 요세미티 사용자가 많이 겪는 버그와 몇몇 불편사항 file hooni 2015.01.04 1522
38 System/OS [mac][추천 무료앱] 구름 입력기 - 국내 맥 사용자를 위한 한글 대안 입력기 1 file hooni 2015.01.04 2152
37 System/OS 개인적으로 쓰고 있는 bash_profile hooni 2015.01.16 844
36 System/OS [windows] 윈도우 사용자 계정 로그인 암호 분실, 암호 변경하는 방법 file hooni 2015.07.09 21358
35 System/OS 맥 OS X 에서 스크린 화면 캡쳐 단축키 (Mac Print Screen) hooni 2015.07.21 1900
Board Pagination Prev 1 ... 8 9 10 11 12 13 14 15 16 17 Next
/ 17