# nginx configuration
map $http_upgrade $connection_upgrade {
default keep-alive; # default is keep-alive,and it can support http request.
'websocket' upgrade; # if configuration is websocket,and the upgrate able to upgrate.
}
server {
listen 443 default_server;
ssl on;
ssl_certificate /path/to/crt;
ssl_certificate_key /path/to/crtkey;
ssl_session_timeout 5m;
ssl_ciphers XXXXXX;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
root /path/to/front/bundle;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name your.servername.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.html;
}
location /test/ {
proxy_pass /path/to/localhost/;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "nginx";
}
location /live/ {
proxy_pass /path/to/live/host/;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Via "nginx";
proxy_set_header Upgrade $http_upgrade; # configure the above variables
proxy_set_header Connection $connection_upgrade;
}
location ~ \.(wasm|mem|js|jpg|png|jpeg|bmp|css)$ {
gzip on;
gzip_comp_level 4;
gzip_types application/octet-stream application/wasm application/javascript application/x-javascript application/css text/javascript image/jpeg image/gif image/png image/x-ms-bmp;
}
add_header Access-Control-Allow-Headers *;
# please open the SharedArrayBuffer by following configuration when using FireFox and Chrome version beyond 92
add_header Cross-Origin-Opener-Policy same-origin;
add_header Cross-Origin-Embedder-Policy require-corp;
add_header Cross-Origin-Resource-Policy cross-origin;
}