# 웹 빌드용 Apache 서버 구성 설정

> Instructions on how to set up your Apache server for your Web build.

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

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

Apache와 설치 및 사용 방법에 대한 상세 내용은 [Apache 기술 자료](https://httpd.apache.org/docs/)를 참조하십시오.

## Apache 웹 빌드 방법 선택##choose-your-apache-web-build-method

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

* `httpd.conf`의 가상 호스트.

* `.htaccess`의 가상 호스트.

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

### `httpd.conf` 메서드에서 가상 호스트 사용##use-the-virtual-host-in-httpd.conf-method

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

```apacheconf
<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.##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##insert-additional-code-here

</IfModule>
</Directory>
```

### `.htaccess` 메서드에서 가상 호스트 사용##use-the-virtual-host-in-.htaccess-method

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

```apacheconf
# NOTE: "mod_mime" Apache module must be enabled for this configuration to work.##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##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##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##the-following-line-improves-loading-performance-for-uncompressed-builds
AddType application/wasm .wasm

# Insert additional code here##insert-additional-code-here

</IfModule>
```

## gzip 압축 빌드의 성능 개선##improve-performance-for-gzip-compressed-builds

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

```
AddEncoding gzip .unityweb
```

## 압축 풀기 폴백이 있는 Brotli 압축 빌드의 성능 개선##improve-performance-for-brotli-compressed-builds-with-decompression-fallback

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

```
 AddEncoding br .unityweb
```

## Enable native C/C++ multithreading##enable-native-c/c++-multithreading

[**플레이어 설정**](/engine/6000.0/manual/platform-specific/webgl/develop/class-player-settings-web-gl.md)에서 **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(크로스 오리진 리소스 공유) 요청 허용##allow-cross-origin-resource-sharing-(cors)-requests

CORS 요청을 허용하려면 다음 코드를 구성에 추가하십시오.

```
 Header add Access-Control-Allow-Origin "*"
```

## 추가 리소스##additional-resources

* [압축된 빌드와 서버 설정](/engine/6000.0/manual/platform-specific/webgl/building-distribution/deploying.md)
* [서버 설정 코드 샘플](/engine/6000.0/manual/platform-specific/webgl/building-distribution/server-configuration-code-samples.md)
* [웹 빌드용 IIS 서버 구성 설정](/engine/6000.0/manual/platform-specific/webgl/building-distribution/server-configuration-code-samples/web-server-config-iis.md)
* [웹 빌드를 위한 Nginx 서버 구성 설정](/engine/6000.0/manual/platform-specific/webgl/building-distribution/server-configuration-code-samples/web-server-config-nginx.md)
* [웹 빌드용 Node.js 서버 구성 설정](/engine/6000.0/manual/platform-specific/webgl/building-distribution/server-configuration-code-samples/web-server-config-nodejs.md)
