Skip to content

Commit

Permalink
Document server setup for CheerpX (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
saarikoski-jules authored Oct 9, 2024
1 parent 209c535 commit 01c7abd
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions sites/cheerpx/src/content/docs/11-guides/nginx.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: Basic server setup
description: Serve your own project using nginx
---

CheerpX requires [SharedArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), which itself requires the site to be cross-origin isolated. This means that the server must set the appropriate headers.

Here's an example of a basic nginx configuration that allows CheerpX to run.

```nginx
worker_processes 1;
error_log nginx_main_error.log info;
pid nginx_user.pid;
daemon off;
events {
worker_connections 1024;
}
http {
default_type application/octet-stream;
access_log nginx_access.log;
error_log nginx_error.log info;
sendfile on;
server {
listen 8080;
server_name localhost;
gzip on;
gzip_types application/javascript application/wasm text/plain application/octet-stream;
charset utf-8;
location / {
root .;
index index.html index.htm;
add_header 'Cross-Origin-Opener-Policy' 'same-origin' always;
add_header 'Cross-Origin-Embedder-Policy' 'require-corp' always;
add_header 'Cross-Origin-Resource-Policy' 'cross-origin' always;
}
}
}
```

This configuration will work over localhost in a development environment. When the application is deployed, it must be served over HTTPS.

Then run nginx using this configuration with the following command line.

```bash
nginx -c nginx.conf -p .
```

0 comments on commit 01c7abd

Please sign in to comment.