본문 바로가기
게임개발/게임개발 팁

[유니티] 웹서버에 유니티 웹게임 올리기(content 헤더 설정)

by 태풍의그라운드 2025. 10. 19.

유니티 WebGL로 빌드하면 웹에서 돌아가는 게임을 만들 수 있다.

ftp로 빌드 파일을 올리고 나면 nginx든 뭐든 서비스 해줄 http서버가 필요하다.

가장 대중적이고 자료가 많은게 nginx이지만 config수정은 아직도 쉽지 않다.

문법도 복잡하고 손에 익지 않아서 매번 인터넷 검색 또는 chatgpt를 활용한다.

 

nginx.conf 설정

 

    # Unity WebGL gzip 파일 처리
    location ~* \.wasm\.gz$ {
        add_header Content-Encoding gzip;
        add_header Content-Type application/wasm;
        try_files $uri =404;
    }

    location ~* \.js\.gz$ {
        add_header Content-Encoding gzip;
        add_header Content-Type application/javascript;
        try_files $uri =404;
    }

    location ~* \.data\.gz$ {
        add_header Content-Encoding gzip;
        add_header Content-Type application/octet-stream;
        try_files $uri =404;
    }

    # 캐시 설정 (선택)
    location ~* \.(wasm|js|data|gz)$ {
        add_header Cache-Control "public, max-age=31536000, immutable";
    }