2022-01-30 21:11:59 +01:00
|
|
|
user nginx;
|
|
|
|
error_log /var/log/nginx/error.log debug;
|
|
|
|
pid /var/run/nginx.pid;
|
|
|
|
worker_processes auto;
|
|
|
|
worker_rlimit_nofile 33282;
|
|
|
|
|
|
|
|
events {
|
|
|
|
worker_connections 1024;
|
|
|
|
}
|
|
|
|
|
|
|
|
http {
|
2022-08-05 18:41:55 +02:00
|
|
|
# rate limiting
|
|
|
|
limit_req_status 429;
|
2022-09-05 10:09:43 +02:00
|
|
|
limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=${PROXY_RATE_LIMIT_API_PER_SECOND}r/s;
|
2022-08-05 18:41:55 +02:00
|
|
|
limit_req_zone $binary_remote_addr zone=webhooks:10m rate=${PROXY_RATE_LIMIT_WEBHOOKS_PER_SECOND}r/s;
|
|
|
|
|
2022-01-30 21:11:59 +01:00
|
|
|
include /etc/nginx/mime.types;
|
|
|
|
default_type application/octet-stream;
|
2022-02-21 11:46:45 +01:00
|
|
|
proxy_set_header Host $host;
|
2022-02-01 14:38:58 +01:00
|
|
|
charset utf-8;
|
|
|
|
sendfile on;
|
|
|
|
tcp_nopush on;
|
|
|
|
tcp_nodelay on;
|
|
|
|
server_tokens off;
|
|
|
|
types_hash_max_size 2048;
|
2022-12-20 17:28:13 +01:00
|
|
|
resolver ${RESOLVER} valid=10s ipv6=off;
|
2022-02-01 14:38:58 +01:00
|
|
|
|
|
|
|
# buffering
|
|
|
|
client_header_buffer_size 1k;
|
2022-03-21 16:24:39 +01:00
|
|
|
client_max_body_size 20M;
|
2022-02-01 14:38:58 +01:00
|
|
|
ignore_invalid_headers off;
|
|
|
|
proxy_buffering off;
|
2022-01-30 21:11:59 +01:00
|
|
|
|
|
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
|
|
'$status $body_bytes_sent "$http_referer" '
|
2022-08-26 14:18:38 +02:00
|
|
|
'"$http_user_agent" "$http_x_forwarded_for" '
|
|
|
|
'response_time=$upstream_response_time proxy_host=$proxy_host upstream_addr=$upstream_addr';
|
|
|
|
|
|
|
|
access_log /var/log/nginx/access.log main;
|
2022-05-05 22:26:57 +02:00
|
|
|
|
2022-01-30 21:11:59 +01:00
|
|
|
map $http_upgrade $connection_upgrade {
|
|
|
|
default "upgrade";
|
|
|
|
}
|
|
|
|
|
2022-02-16 14:12:53 +01:00
|
|
|
server {
|
2022-01-30 21:11:59 +01:00
|
|
|
listen 10000 default_server;
|
2022-02-11 15:13:31 +01:00
|
|
|
listen [::]:10000 default_server;
|
2022-01-30 21:11:59 +01:00
|
|
|
server_name _;
|
2022-02-16 14:12:53 +01:00
|
|
|
client_max_body_size 1000m;
|
|
|
|
ignore_invalid_headers off;
|
|
|
|
proxy_buffering off;
|
2022-05-05 22:26:57 +02:00
|
|
|
|
2022-04-04 16:22:31 +02:00
|
|
|
set $csp_default "default-src 'self'";
|
2022-11-08 11:22:26 +01:00
|
|
|
set $csp_script "script-src 'self' 'unsafe-inline' 'unsafe-eval' https://*.budibase.net https://cdn.budi.live https://js.intercomcdn.com https://widget.intercom.io";
|
2022-03-31 13:09:55 +02:00
|
|
|
set $csp_style "style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com https://rsms.me https://maxcdn.bootstrapcdn.com";
|
|
|
|
set $csp_object "object-src 'none'";
|
|
|
|
set $csp_base_uri "base-uri 'self'";
|
2023-09-21 10:07:50 +02:00
|
|
|
set $csp_connect "connect-src 'self' https://*.budibase.app https://*.budibaseqa.app https://*.budibase.net https://api-iam.intercom.io https://api-iam.intercom.io https://api-ping.intercom.io https://app.posthog.com wss://nexus-websocket-a.intercom.io wss://nexus-websocket-b.intercom.io https://nexus-websocket-a.intercom.io https://nexus-websocket-b.intercom.io https://uploads.intercomcdn.com https://uploads.intercomusercontent.com https://*.amazonaws.com https://*.s3.amazonaws.com https://*.s3.us-east-2.amazonaws.com https://*.s3.us-east-1.amazonaws.com https://*.s3.us-west-1.amazonaws.com https://*.s3.us-west-2.amazonaws.com https://*.s3.af-south-1.amazonaws.com https://*.s3.ap-east-1.amazonaws.com https://*.s3.ap-southeast-3.amazonaws.com https://*.s3.ap-south-1.amazonaws.com https://*.s3.ap-northeast-3.amazonaws.com https://*.s3.ap-northeast-2.amazonaws.com https://*.s3.ap-southeast-1.amazonaws.com https://*.s3.ap-southeast-2.amazonaws.com https://*.s3.ap-northeast-1.amazonaws.com https://*.s3.ca-central-1.amazonaws.com https://*.s3.cn-north-1.amazonaws.com https://*.s3.cn-northwest-1.amazonaws.com https://*.s3.eu-central-1.amazonaws.com https://*.s3.eu-west-1.amazonaws.com https://*.s3.eu-west-2.amazonaws.com https://*.s3.eu-south-1.amazonaws.com https://*.s3.eu-west-3.amazonaws.com https://*.s3.eu-north-1.amazonaws.com https://*.s3.sa-east-1.amazonaws.com https://*.s3.me-south-1.amazonaws.com https://*.s3.us-gov-east-1.amazonaws.com https://*.s3.us-gov-west-1.amazonaws.com https://api.github.com";
|
2023-03-07 15:45:11 +01:00
|
|
|
set $csp_font "font-src 'self' data: https://cdn.jsdelivr.net https://fonts.gstatic.com https://rsms.me https://maxcdn.bootstrapcdn.com https://js.intercomcdn.com https://fonts.intercomcdn.com";
|
2022-03-31 13:09:55 +02:00
|
|
|
set $csp_frame "frame-src 'self' https:";
|
|
|
|
set $csp_img "img-src http: https: data: blob:";
|
|
|
|
set $csp_manifest "manifest-src 'self'";
|
2023-03-06 18:33:56 +01:00
|
|
|
set $csp_media "media-src 'self' https://js.intercomcdn.com https://cdn.budi.live";
|
2022-03-31 13:09:55 +02:00
|
|
|
set $csp_worker "worker-src 'none'";
|
2022-01-30 21:11:59 +01:00
|
|
|
|
2022-03-31 16:58:45 +02:00
|
|
|
error_page 502 503 504 /error.html;
|
|
|
|
location = /error.html {
|
2022-05-05 22:26:57 +02:00
|
|
|
root /usr/share/nginx/html;
|
2022-03-31 16:58:45 +02:00
|
|
|
internal;
|
|
|
|
}
|
|
|
|
|
2022-01-30 21:11:59 +01:00
|
|
|
# Security Headers
|
|
|
|
add_header X-Frame-Options SAMEORIGIN always;
|
|
|
|
add_header X-Content-Type-Options nosniff always;
|
|
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
2022-04-04 16:22:31 +02:00
|
|
|
add_header Content-Security-Policy "${csp_default}; ${csp_script}; ${csp_style}; ${csp_object}; ${csp_base_uri}; ${csp_connect}; ${csp_font}; ${csp_frame}; ${csp_img}; ${csp_manifest}; ${csp_media}; ${csp_worker};" always;
|
2022-02-16 14:12:53 +01:00
|
|
|
|
|
|
|
# upstreams
|
2022-12-20 17:28:13 +01:00
|
|
|
set $apps ${APPS_UPSTREAM_URL};
|
|
|
|
set $worker ${WORKER_UPSTREAM_URL};
|
|
|
|
set $minio ${MINIO_UPSTREAM_URL};
|
|
|
|
set $couchdb ${COUCHDB_UPSTREAM_URL};
|
|
|
|
set $watchtower ${WATCHTOWER_UPSTREAM_URL};
|
2022-01-30 21:11:59 +01:00
|
|
|
|
2023-05-09 12:48:49 +02:00
|
|
|
location /health {
|
|
|
|
access_log off;
|
|
|
|
add_header 'Content-Type' 'application/json';
|
|
|
|
return 200 '{ "status": "OK" }';
|
|
|
|
}
|
|
|
|
|
2022-01-30 21:11:59 +01:00
|
|
|
location /app {
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $apps;
|
2022-01-30 21:11:59 +01:00
|
|
|
}
|
|
|
|
|
2023-06-16 13:30:08 +02:00
|
|
|
location /embed {
|
|
|
|
rewrite /embed/(.*) /app/$1 break;
|
|
|
|
proxy_pass $apps;
|
|
|
|
proxy_redirect off;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_set_header x-budibase-embed "true";
|
|
|
|
add_header x-budibase-embed "true";
|
|
|
|
add_header Content-Security-Policy "frame-ancestors *";
|
|
|
|
}
|
|
|
|
|
2022-01-30 21:11:59 +01:00
|
|
|
location = / {
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $apps;
|
2022-01-30 21:11:59 +01:00
|
|
|
}
|
|
|
|
|
2022-02-16 14:12:53 +01:00
|
|
|
location = /v1/update {
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $watchtower;
|
2022-01-30 21:11:59 +01:00
|
|
|
}
|
2022-08-23 09:50:36 +02:00
|
|
|
|
2022-02-11 19:04:27 +01:00
|
|
|
location ~ ^/(builder|app_) {
|
|
|
|
proxy_http_version 1.1;
|
2022-11-09 17:35:16 +01:00
|
|
|
|
2022-02-11 19:04:27 +01:00
|
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
2022-11-09 17:35:16 +01:00
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $apps;
|
2022-01-30 21:11:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
location ~ ^/api/(system|admin|global)/ {
|
2022-11-09 17:35:16 +01:00
|
|
|
proxy_set_header Host $host;
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $worker;
|
2022-01-30 21:11:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
location /worker/ {
|
2022-11-09 17:35:16 +01:00
|
|
|
proxy_set_header Host $host;
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $worker;
|
2022-01-30 21:11:59 +01:00
|
|
|
rewrite ^/worker/(.*)$ /$1 break;
|
|
|
|
}
|
|
|
|
|
2022-11-09 12:33:57 +01:00
|
|
|
location /api/backups/ {
|
2022-11-15 11:49:17 +01:00
|
|
|
# calls to export apps are limited
|
|
|
|
limit_req zone=ratelimit burst=20 nodelay;
|
|
|
|
|
|
|
|
# 1800s timeout for app export requests
|
2022-11-09 12:33:57 +01:00
|
|
|
proxy_read_timeout 1800s;
|
|
|
|
proxy_connect_timeout 1800s;
|
|
|
|
proxy_send_timeout 1800s;
|
2022-11-15 11:49:17 +01:00
|
|
|
|
2022-11-09 12:33:57 +01:00
|
|
|
proxy_http_version 1.1;
|
2022-11-15 11:49:17 +01:00
|
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $apps;
|
2022-11-09 12:33:57 +01:00
|
|
|
}
|
|
|
|
|
2022-01-30 21:11:59 +01:00
|
|
|
location /api/ {
|
|
|
|
# calls to the API are rate limited with bursting
|
2022-02-14 17:39:10 +01:00
|
|
|
limit_req zone=ratelimit burst=20 nodelay;
|
2022-01-30 21:11:59 +01:00
|
|
|
|
|
|
|
# 120s timeout on API requests
|
|
|
|
proxy_read_timeout 120s;
|
|
|
|
proxy_connect_timeout 120s;
|
2022-02-16 14:12:53 +01:00
|
|
|
proxy_send_timeout 120s;
|
2022-01-30 21:11:59 +01:00
|
|
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
2022-08-05 18:41:55 +02:00
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
2022-11-09 17:35:16 +01:00
|
|
|
proxy_set_header Host $host;
|
2022-08-05 18:41:55 +02:00
|
|
|
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $apps;
|
2022-08-05 18:41:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
location /api/webhooks/ {
|
|
|
|
# calls to webhooks are rate limited
|
|
|
|
limit_req zone=webhooks nodelay;
|
|
|
|
|
|
|
|
# Rest of configuration copied from /api/ location above
|
|
|
|
# 120s timeout on API requests
|
|
|
|
proxy_read_timeout 120s;
|
|
|
|
proxy_connect_timeout 120s;
|
|
|
|
proxy_send_timeout 120s;
|
|
|
|
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Connection $connection_upgrade;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
2022-01-30 21:11:59 +01:00
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
2022-11-09 17:35:16 +01:00
|
|
|
proxy_set_header Host $host;
|
2022-01-30 21:11:59 +01:00
|
|
|
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $apps;
|
2022-01-30 21:11:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
location /db/ {
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $couchdb;
|
2022-01-30 21:11:59 +01:00
|
|
|
rewrite ^/db/(.*)$ /$1 break;
|
|
|
|
}
|
|
|
|
|
2022-09-02 13:26:30 +02:00
|
|
|
location /socket/ {
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
|
|
proxy_set_header Connection 'upgrade';
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
proxy_cache_bypass $http_upgrade;
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $apps;
|
2022-09-02 13:26:30 +02:00
|
|
|
}
|
|
|
|
|
2022-01-30 21:11:59 +01:00
|
|
|
location / {
|
|
|
|
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 $scheme;
|
2022-10-26 19:51:58 +02:00
|
|
|
proxy_set_header Host $http_host;
|
2022-02-11 19:04:27 +01:00
|
|
|
|
|
|
|
proxy_connect_timeout 300;
|
2022-02-16 14:12:53 +01:00
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Connection "";
|
|
|
|
chunked_transfer_encoding off;
|
2022-10-26 19:51:58 +02:00
|
|
|
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $minio;
|
2022-01-30 21:11:59 +01:00
|
|
|
}
|
|
|
|
|
2022-12-15 12:35:22 +01:00
|
|
|
location /files/signed/ {
|
|
|
|
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 $scheme;
|
|
|
|
|
|
|
|
# IMPORTANT: Signed urls will inspect the host header of the request.
|
|
|
|
# Normally a signed url will need to be generated with a specified client host in mind.
|
|
|
|
# To support dynamic hosts, e.g. some unknown self-hosted installation url,
|
|
|
|
# use a predefined host header. The host 'minio-service' is also used at the time of url signing.
|
|
|
|
proxy_set_header Host minio-service;
|
|
|
|
|
|
|
|
proxy_connect_timeout 300;
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Connection "";
|
|
|
|
chunked_transfer_encoding off;
|
|
|
|
|
2022-12-20 17:28:13 +01:00
|
|
|
proxy_pass $minio;
|
2022-12-15 12:35:22 +01:00
|
|
|
rewrite ^/files/signed/(.*)$ /$1 break;
|
|
|
|
}
|
|
|
|
|
2023-04-21 18:25:55 +02:00
|
|
|
client_header_timeout 120;
|
|
|
|
client_body_timeout 120;
|
|
|
|
keepalive_timeout 120;
|
2022-02-01 14:38:58 +01:00
|
|
|
|
|
|
|
# gzip
|
|
|
|
gzip on;
|
|
|
|
gzip_vary on;
|
|
|
|
gzip_proxied any;
|
|
|
|
gzip_comp_level 6;
|
|
|
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
|
2022-01-30 21:11:59 +01:00
|
|
|
}
|
2022-05-05 22:26:57 +02:00
|
|
|
}
|