mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 00:27:41 +01:00
79 lines
2.2 KiB
Plaintext
79 lines
2.2 KiB
Plaintext
# This template is used to generate the default.conf file for the nginx server,
|
|
# by using `envsubst` to replace the environment variables in the template with
|
|
# their actual values.
|
|
|
|
# Helper to get scheme regardless if we are behind a proxy or not
|
|
map $http_x_forwarded_proto $forwardscheme {
|
|
default $scheme;
|
|
https https;
|
|
}
|
|
|
|
# COEP and COOP headers for cross-origin isolation, which are set only for the
|
|
# EmulatorJS player path, to enable SharedArrayBuffer support, which is needed
|
|
# for multi-threaded cores.
|
|
map $request_uri $coep_header {
|
|
default "";
|
|
~^/rom/.*/ejs$ "require-corp";
|
|
}
|
|
map $request_uri $coop_header {
|
|
default "";
|
|
~^/rom/.*/ejs$ "same-origin";
|
|
}
|
|
|
|
server {
|
|
root /var/www/html;
|
|
listen ${ROMM_PORT};
|
|
${IPV6_LISTEN}
|
|
server_name localhost;
|
|
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $forwardscheme;
|
|
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
proxy_redirect off;
|
|
add_header Access-Control-Allow-Origin *;
|
|
add_header Access-Control-Allow-Methods *;
|
|
add_header Access-Control-Allow-Headers *;
|
|
add_header Cross-Origin-Embedder-Policy $coep_header;
|
|
add_header Cross-Origin-Opener-Policy $coop_header;
|
|
}
|
|
|
|
# Static files
|
|
location /assets {
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
# OpenAPI for swagger and redoc
|
|
location /openapi.json {
|
|
proxy_pass http://wsgi_server;
|
|
}
|
|
|
|
# Backend api calls
|
|
location /api {
|
|
proxy_pass http://wsgi_server;
|
|
proxy_request_buffering off;
|
|
proxy_buffering off;
|
|
}
|
|
location /ws {
|
|
proxy_pass http://wsgi_server;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
}
|
|
|
|
# Internally redirect download requests
|
|
location /library/ {
|
|
internal;
|
|
alias "${ROMM_BASE_PATH}/library/";
|
|
}
|
|
|
|
# Internal decoding endpoint, used to decode base64 encoded data
|
|
location /decode {
|
|
internal;
|
|
js_content decode.decodeBase64;
|
|
}
|
|
}
|