55 lines
1.5 KiB
Plaintext

server {
listen 80;
listen [::]:80;
server_name localhost;
root /usr/share/nginx/html;
include variables.conf;
js_path "/etc/nginx/njs/";
js_import redirect from redirect.js;
absolute_redirect off;
# disable http://example.org/index as a duplicate content
location = /index { return 404; }
location ~ ^/docs/((\d+\.\d+|next)/)?redirect$ {
js_content redirect.redirectToPageId;
}
include redirects.conf;
if ($http_x_hot_enable_latest_redirects = "1") {
include redirects-autogenerated.conf;
}
# Rule allows run "Saving data" examples in JSFiddle or any code runner (#9398)
location ~ ^/docs/((\d+\.\d+|next)/)?scripts/json/(load|save).json$ {
# Preflighted requests
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Origin "*";
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS, HEAD";
add_header Access-Control-Allow-Headers "Content-Type, Accept";
return 200;
}
if ($request_method ~* "(GET|POST)") {
add_header Access-Control-Allow-Origin "*";
}
# Fix for HTTP 405 errors. Thanks to that the save.json file can be served as if it were
# a GET request even though it is a POST request.
error_page 405 =200 $uri;
}
location ~ {
index index.html;
try_files $uri/index.html $uri $uri.html =404;
}
error_page 404 =404 /docs/404.html;
error_page 403 =403 /docs/403.html;
}