Version: Unity 6.0 (6000.0)
언어 : 한국어
서버 설정 코드 샘플
웹 빌드용 IIS 서버 구성 설정

웹 빌드용 Apache 서버 구성 설정

Unity 웹 빌드에서 Apache 서버를 사용하도록 Apache 서버 구성 파일을 설정합니다.

Apache는 Unity 웹으로로 만든 애플리케이션을 제공하는 데 사용할 수 있는 오픈 소스 크로스 플랫폼 웹 서버입니다.

Apache와 설치 및 사용 방법에 대한 상세 내용은 Apache 기술 자료를 참조하십시오.

Apache 웹 빌드 방법 선택

다음 두 가지 방법 중 하나를 사용하여 Apache 웹 빌드를 설정할 수 있습니다.

  • httpd.conf의 가상 호스트.

  • .htaccess의 가상 호스트.

가장 좋은 방법은 해당 구성에 액세스할 수 있는 경우 Apache의 httpd.conf에서 가상 호스트를 구성하는 것입니다.

httpd.conf 메서드에서 가상 호스트 사용

httpd.conf 메서드에서 가상 호스트를 사용하여 웹 빌드를 구성하려면 Apache 서버 구성에서 다음 코드를 사용하십시오.

<Directory /var/www/html/root/path/to/your/unity/content/>
<IfModule mod_mime.c>
RemoveType .gz
AddEncoding gzip .gz
# The correct MIME type for .data.gz would be application/octet-stream, but due to Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421, it is preferable to use MIME Type application/gzip instead.
#AddType application/octet-stream .data.gz
AddType application/gzip .data.gz
AddType application/wasm .wasm.gz
AddType application/javascript .js.gz
AddType application/octet-stream .symbols.json.gz

RemoveType .br
AddEncoding br .br
AddType application/octet-stream .data.br
AddType application/wasm .wasm.br
AddType application/javascript .js.br
AddType application/octet-stream .symbols.json.br

# Insert additional code here

</IfModule>
</Directory>

.htaccess 메서드에서 가상 호스트 사용

예를 들어 웹 호스팅에 대한 관리자 권한을 사용할 수 없어 httpd.conf를 수정할 수 없지만 Apache가 .htaccess를 지원하는 경우 다음과 같은 방법으로 .htaccess를 설정할 수 있습니다.

# NOTE: "mod_mime" Apache module must be enabled for this configuration to work.
<IfModule mod_mime.c>

# The following lines are required for builds without decompression fallback, compressed with gzip
RemoveType .gz
AddEncoding gzip .gz
AddType application/gzip .data.gz # The correct MIME type here would be application/octet-stream, but due to Safari bug https://bugs.webkit.org/show_bug.cgi?id=247421, it's preferable to use MIME Type application/gzip instead.
AddType application/wasm .wasm.gz
AddType application/javascript .js.gz
AddType application/octet-stream .symbols.json.gz

# The following lines are required for builds without decompression fallback, compressed with Brotli
RemoveType .br
RemoveLanguage .br
AddEncoding br .br
AddType application/octet-stream .data.br
AddType application/wasm .wasm.br
AddType application/javascript .js.br
AddType application/octet-stream .symbols.json.br

# The following line improves loading performance for uncompressed builds
AddType application/wasm .wasm

# Insert additional code here

</IfModule>

gzip 압축 빌드의 성능 개선

압축 풀기 폴백이 있는 gzip 압축 웹 빌드의 로딩 성능을 개선하려면 코드에 다음 라인을 추가하십시오.

AddEncoding gzip .unityweb

압축 풀기 폴백이 있는 Brotli 압축 빌드의 성능 개선

압축 풀기 폴백이 있는 Brotli 압축 빌드의 로딩 성능을 개선하려면 구성에 다음 코드 줄을 추가하십시오.

 AddEncoding br .unityweb

Enable native C/C++ multithreading

플레이어 설정에서 Enable Native C/C++ Multithreading을 활성화하여 빌드를 생성한 경우, 구성 파일에 다음 코드를 추가하십시오.

 <FilesMatch "\.(htm|html|js|js.gz|js.br)$">
     Header add Cross-Origin-Opener-Policy "same-origin"
     Header add Cross-Origin-Embedder-Policy "require-corp"
     Header add Cross-Origin-Resource-Policy "cross-origin"
 </FilesMatch>

CORS(크로스 오리진 리소스 공유) 요청 허용

CORS 요청을 허용하려면 다음 코드를 구성에 추가하십시오. Header add Access-Control-Allow-Origin "*"

추가 리소스

서버 설정 코드 샘플
웹 빌드용 IIS 서버 구성 설정