forked from tsai/budibase
329 changed files with 8866 additions and 5616 deletions
@ -1 +0,0 @@ |
|||||
hosting.properties |
|
||||
@ -0,0 +1,21 @@ |
|||||
|
# Use the main port in the builder for your self hosting URL, e.g. localhost:10000 |
||||
|
MAIN_PORT=10000 |
||||
|
|
||||
|
# This section contains all secrets pertaining to the system |
||||
|
# These should be updated |
||||
|
JWT_SECRET=testsecret |
||||
|
MINIO_ACCESS_KEY=budibase |
||||
|
MINIO_SECRET_KEY=budibase |
||||
|
COUCH_DB_PASSWORD=budibase |
||||
|
COUCH_DB_USER=budibase |
||||
|
REDIS_PASSWORD=budibase |
||||
|
INTERNAL_API_KEY=budibase |
||||
|
|
||||
|
# This section contains variables that do not need to be altered under normal circumstances |
||||
|
APP_PORT=4002 |
||||
|
WORKER_PORT=4003 |
||||
|
MINIO_PORT=4004 |
||||
|
COUCH_DB_PORT=4005 |
||||
|
REDIS_PORT=6379 |
||||
|
WATCHTOWER_PORT=6161 |
||||
|
BUDIBASE_ENVIRONMENT=PRODUCTION |
||||
@ -1,149 +0,0 @@ |
|||||
static_resources: |
|
||||
listeners: |
|
||||
- name: main_listener |
|
||||
address: |
|
||||
socket_address: { address: 0.0.0.0, port_value: 10000 } |
|
||||
filter_chains: |
|
||||
- filters: |
|
||||
- name: envoy.filters.network.http_connection_manager |
|
||||
typed_config: |
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager |
|
||||
stat_prefix: ingress |
|
||||
codec_type: auto |
|
||||
route_config: |
|
||||
name: local_route |
|
||||
virtual_hosts: |
|
||||
- name: local_services |
|
||||
domains: ["*"] |
|
||||
routes: |
|
||||
# special case to redirect specifically the route path |
|
||||
# to the builder, if this were a prefix then it would break minio |
|
||||
- match: { path: "/" } |
|
||||
redirect: { path_redirect: "/builder/" } |
|
||||
|
|
||||
- match: { prefix: "/db/" } |
|
||||
route: |
|
||||
cluster: couchdb-service |
|
||||
prefix_rewrite: "/" |
|
||||
|
|
||||
- match: { prefix: "/api/system/" } |
|
||||
route: |
|
||||
cluster: worker-dev |
|
||||
|
|
||||
- match: { prefix: "/api/admin/" } |
|
||||
route: |
|
||||
cluster: worker-dev |
|
||||
|
|
||||
- match: { prefix: "/api/global/" } |
|
||||
route: |
|
||||
cluster: worker-dev |
|
||||
|
|
||||
- match: { prefix: "/api/" } |
|
||||
route: |
|
||||
cluster: server-dev |
|
||||
timeout: 120s |
|
||||
|
|
||||
- match: { prefix: "/app_" } |
|
||||
route: |
|
||||
cluster: server-dev |
|
||||
|
|
||||
- match: { prefix: "/app/" } |
|
||||
route: |
|
||||
cluster: server-dev |
|
||||
prefix_rewrite: "/" |
|
||||
|
|
||||
# the below three cases are needed to make sure |
|
||||
# all traffic prefixed for the builder is passed through |
|
||||
# correctly. |
|
||||
- match: { path: "/" } |
|
||||
route: |
|
||||
cluster: builder-dev |
|
||||
|
|
||||
- match: { prefix: "/builder/" } |
|
||||
route: |
|
||||
cluster: builder-dev |
|
||||
|
|
||||
- match: { prefix: "/builder" } |
|
||||
route: |
|
||||
cluster: builder-dev |
|
||||
prefix_rewrite: "/builder/" |
|
||||
|
|
||||
# minio is on the default route because this works |
|
||||
# best, minio + AWS SDK doesn't handle path proxy |
|
||||
- match: { prefix: "/" } |
|
||||
route: |
|
||||
cluster: minio-service |
|
||||
|
|
||||
http_filters: |
|
||||
- name: envoy.filters.http.router |
|
||||
|
|
||||
clusters: |
|
||||
- name: minio-service |
|
||||
connect_timeout: 0.25s |
|
||||
type: strict_dns |
|
||||
lb_policy: round_robin |
|
||||
load_assignment: |
|
||||
cluster_name: minio-service |
|
||||
endpoints: |
|
||||
- lb_endpoints: |
|
||||
- endpoint: |
|
||||
address: |
|
||||
socket_address: |
|
||||
address: minio-service |
|
||||
port_value: 9000 |
|
||||
|
|
||||
- name: couchdb-service |
|
||||
connect_timeout: 0.25s |
|
||||
type: strict_dns |
|
||||
lb_policy: round_robin |
|
||||
load_assignment: |
|
||||
cluster_name: couchdb-service |
|
||||
endpoints: |
|
||||
- lb_endpoints: |
|
||||
- endpoint: |
|
||||
address: |
|
||||
socket_address: |
|
||||
address: couchdb-service |
|
||||
port_value: 5984 |
|
||||
|
|
||||
- name: server-dev |
|
||||
connect_timeout: 0.25s |
|
||||
type: strict_dns |
|
||||
lb_policy: round_robin |
|
||||
load_assignment: |
|
||||
cluster_name: server-dev |
|
||||
endpoints: |
|
||||
- lb_endpoints: |
|
||||
- endpoint: |
|
||||
address: |
|
||||
socket_address: |
|
||||
address: {{ address }} |
|
||||
port_value: 4001 |
|
||||
|
|
||||
- name: builder-dev |
|
||||
connect_timeout: 15s |
|
||||
type: strict_dns |
|
||||
lb_policy: round_robin |
|
||||
load_assignment: |
|
||||
cluster_name: builder-dev |
|
||||
endpoints: |
|
||||
- lb_endpoints: |
|
||||
- endpoint: |
|
||||
address: |
|
||||
socket_address: |
|
||||
address: {{ address }} |
|
||||
port_value: 3000 |
|
||||
|
|
||||
- name: worker-dev |
|
||||
connect_timeout: 0.25s |
|
||||
type: strict_dns |
|
||||
lb_policy: round_robin |
|
||||
load_assignment: |
|
||||
cluster_name: worker-dev |
|
||||
endpoints: |
|
||||
- lb_endpoints: |
|
||||
- endpoint: |
|
||||
address: |
|
||||
socket_address: |
|
||||
address: {{ address }} |
|
||||
port_value: 4002 |
|
||||
@ -1,21 +0,0 @@ |
|||||
# Use the main port in the builder for your self hosting URL, e.g. localhost:10000 |
|
||||
MAIN_PORT=10000 |
|
||||
|
|
||||
# This section contains all secrets pertaining to the system |
|
||||
# These should be updated |
|
||||
JWT_SECRET=testsecret |
|
||||
MINIO_ACCESS_KEY=budibase |
|
||||
MINIO_SECRET_KEY=budibase |
|
||||
COUCH_DB_PASSWORD=budibase |
|
||||
COUCH_DB_USER=budibase |
|
||||
REDIS_PASSWORD=budibase |
|
||||
INTERNAL_API_KEY=budibase |
|
||||
|
|
||||
# This section contains variables that do not need to be altered under normal circumstances |
|
||||
APP_PORT=4002 |
|
||||
WORKER_PORT=4003 |
|
||||
MINIO_PORT=4004 |
|
||||
COUCH_DB_PORT=4005 |
|
||||
REDIS_PORT=6379 |
|
||||
WATCHTOWER_PORT=6161 |
|
||||
BUDIBASE_ENVIRONMENT=PRODUCTION |
|
||||
@ -1,4 +0,0 @@ |
|||||
FROM envoyproxy/envoy:v1.16-latest |
|
||||
COPY envoy.yaml /etc/envoy/envoy.yaml |
|
||||
RUN chmod go+r /etc/envoy/envoy.yaml |
|
||||
|
|
||||
@ -1,146 +0,0 @@ |
|||||
static_resources: |
|
||||
listeners: |
|
||||
- name: main_listener |
|
||||
address: |
|
||||
socket_address: { address: 0.0.0.0, port_value: 10000 } |
|
||||
filter_chains: |
|
||||
- filters: |
|
||||
- name: envoy.filters.network.http_connection_manager |
|
||||
typed_config: |
|
||||
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager |
|
||||
stat_prefix: ingress |
|
||||
codec_type: auto |
|
||||
route_config: |
|
||||
name: local_route |
|
||||
virtual_hosts: |
|
||||
- name: local_services |
|
||||
domains: ["*"] |
|
||||
routes: |
|
||||
- match: { prefix: "/app/" } |
|
||||
route: |
|
||||
cluster: app-service |
|
||||
prefix_rewrite: "/" |
|
||||
|
|
||||
- match: { prefix: "/builder/" } |
|
||||
route: |
|
||||
cluster: app-service |
|
||||
|
|
||||
- match: { prefix: "/builder" } |
|
||||
route: |
|
||||
cluster: app-service |
|
||||
|
|
||||
- match: { prefix: "/app_" } |
|
||||
route: |
|
||||
cluster: app-service |
|
||||
|
|
||||
# special cases for worker admin (deprecated), global and system API |
|
||||
- match: { prefix: "/api/global/" } |
|
||||
route: |
|
||||
cluster: worker-service |
|
||||
|
|
||||
- match: { prefix: "/api/admin/" } |
|
||||
route: |
|
||||
cluster: worker-service |
|
||||
|
|
||||
- match: { prefix: "/api/system/" } |
|
||||
route: |
|
||||
cluster: worker-service |
|
||||
|
|
||||
- match: { path: "/" } |
|
||||
route: |
|
||||
cluster: app-service |
|
||||
|
|
||||
- match: |
|
||||
safe_regex: |
|
||||
google_re2: {} |
|
||||
regex: "/api/.*/export" |
|
||||
route: |
|
||||
timeout: 0s |
|
||||
cluster: app-service |
|
||||
|
|
||||
- match: { path: "/api/deploy" } |
|
||||
route: |
|
||||
timeout: 60s |
|
||||
cluster: app-service |
|
||||
|
|
||||
# special case for when API requests are made, can just forward, not to minio |
|
||||
- match: { prefix: "/api/" } |
|
||||
route: |
|
||||
cluster: app-service |
|
||||
|
|
||||
- match: { prefix: "/worker/" } |
|
||||
route: |
|
||||
cluster: worker-service |
|
||||
prefix_rewrite: "/" |
|
||||
|
|
||||
- match: { prefix: "/db/" } |
|
||||
route: |
|
||||
cluster: couchdb-service |
|
||||
prefix_rewrite: "/" |
|
||||
|
|
||||
# minio is on the default route because this works |
|
||||
# best, minio + AWS SDK doesn't handle path proxy |
|
||||
- match: { prefix: "/" } |
|
||||
route: |
|
||||
cluster: minio-service |
|
||||
|
|
||||
http_filters: |
|
||||
- name: envoy.filters.http.router |
|
||||
|
|
||||
clusters: |
|
||||
- name: app-service |
|
||||
connect_timeout: 0.25s |
|
||||
type: strict_dns |
|
||||
lb_policy: round_robin |
|
||||
load_assignment: |
|
||||
cluster_name: app-service |
|
||||
endpoints: |
|
||||
- lb_endpoints: |
|
||||
- endpoint: |
|
||||
address: |
|
||||
socket_address: |
|
||||
address: app-service.budibase.svc.cluster.local |
|
||||
port_value: 4002 |
|
||||
|
|
||||
- name: minio-service |
|
||||
connect_timeout: 0.25s |
|
||||
type: strict_dns |
|
||||
lb_policy: round_robin |
|
||||
load_assignment: |
|
||||
cluster_name: minio-service |
|
||||
endpoints: |
|
||||
- lb_endpoints: |
|
||||
- endpoint: |
|
||||
address: |
|
||||
socket_address: |
|
||||
address: minio-service.budibase.svc.cluster.local |
|
||||
port_value: 9000 |
|
||||
|
|
||||
- name: worker-service |
|
||||
connect_timeout: 0.25s |
|
||||
type: strict_dns |
|
||||
lb_policy: round_robin |
|
||||
load_assignment: |
|
||||
cluster_name: worker-service |
|
||||
endpoints: |
|
||||
- lb_endpoints: |
|
||||
- endpoint: |
|
||||
address: |
|
||||
socket_address: |
|
||||
address: worker-service.budibase.svc.cluster.local |
|
||||
port_value: 4001 |
|
||||
|
|
||||
- name: couchdb-service |
|
||||
connect_timeout: 0.25s |
|
||||
type: strict_dns |
|
||||
lb_policy: round_robin |
|
||||
load_assignment: |
|
||||
cluster_name: couchdb-service |
|
||||
endpoints: |
|
||||
- lb_endpoints: |
|
||||
- endpoint: |
|
||||
address: |
|
||||
socket_address: |
|
||||
address: budibase-prod-svc-couchdb |
|
||||
port_value: 5984 |
|
||||
|
|
||||
@ -0,0 +1,2 @@ |
|||||
|
FROM nginx:latest |
||||
|
COPY nginx.conf /etc/nginx/nginx.conf |
||||
@ -0,0 +1,141 @@ |
|||||
|
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 { |
||||
|
limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=10r/s; |
||||
|
include /etc/nginx/mime.types; |
||||
|
default_type application/octet-stream; |
||||
|
charset utf-8; |
||||
|
sendfile on; |
||||
|
tcp_nopush on; |
||||
|
tcp_nodelay on; |
||||
|
server_tokens off; |
||||
|
types_hash_max_size 2048; |
||||
|
|
||||
|
# buffering |
||||
|
client_body_buffer_size 1K; |
||||
|
client_header_buffer_size 1k; |
||||
|
client_max_body_size 10M; |
||||
|
ignore_invalid_headers off; |
||||
|
proxy_buffering off; |
||||
|
|
||||
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
||||
|
'$status $body_bytes_sent "$http_referer" ' |
||||
|
'"$http_user_agent" "$http_x_forwarded_for"'; |
||||
|
|
||||
|
map $http_upgrade $connection_upgrade { |
||||
|
default "upgrade"; |
||||
|
} |
||||
|
|
||||
|
server { |
||||
|
listen 10000 default_server; |
||||
|
listen [::]:10000 default_server; |
||||
|
server_name _; |
||||
|
port_in_redirect off; |
||||
|
|
||||
|
# 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; |
||||
|
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.budi.live https://js.intercomcdn.com https://widget.intercom.io; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com https://rsms.me; object-src 'none'; base-uri 'self'; connect-src 'self' https://api-iam.intercom.io https://app.posthog.com wss://nexus-websocket-a.intercom.io; font-src 'self' data: https://cdn.jsdelivr.net https://fonts.gstatic.com https://rsms.me; frame-src 'self'; img-src http: https: data:; manifest-src 'self'; media-src 'self'; worker-src 'none';" always; |
||||
|
|
||||
|
location /app { |
||||
|
proxy_pass http://app-service.budibase.svc.cluster.local:4002; |
||||
|
rewrite ^/app/(.*)$ /$1 break; |
||||
|
} |
||||
|
|
||||
|
location = / { |
||||
|
proxy_http_version 1.1; |
||||
|
proxy_set_header Connection $connection_upgrade; |
||||
|
proxy_set_header Upgrade $http_upgrade; |
||||
|
proxy_set_header Host $host; |
||||
|
proxy_set_header X-Real-IP $remote_addr; |
||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
|
proxy_pass http://app-service.budibase.svc.cluster.local:4002; |
||||
|
} |
||||
|
|
||||
|
location /builder/ { |
||||
|
proxy_http_version 1.1; |
||||
|
proxy_set_header Connection $connection_upgrade; |
||||
|
proxy_set_header Upgrade $http_upgrade; |
||||
|
proxy_set_header Host $host; |
||||
|
proxy_set_header X-Real-IP $remote_addr; |
||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
|
proxy_pass http://app-service.budibase.svc.cluster.local:4002; |
||||
|
} |
||||
|
|
||||
|
location ~ ^/(builder|app_) { |
||||
|
proxy_http_version 1.1; |
||||
|
proxy_set_header Connection $connection_upgrade; |
||||
|
proxy_set_header Upgrade $http_upgrade; |
||||
|
proxy_set_header Host $host; |
||||
|
proxy_set_header X-Real-IP $remote_addr; |
||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
|
proxy_pass http://app-service.budibase.svc.cluster.local:4002; |
||||
|
} |
||||
|
|
||||
|
location ~ ^/api/(system|admin|global)/ { |
||||
|
proxy_pass http://worker-service.budibase.svc.cluster.local:4001; |
||||
|
} |
||||
|
|
||||
|
location /worker/ { |
||||
|
proxy_pass http://worker-service.budibase.svc.cluster.local:4001; |
||||
|
rewrite ^/worker/(.*)$ /$1 break; |
||||
|
} |
||||
|
|
||||
|
location /api/ { |
||||
|
# calls to the API are rate limited with bursting |
||||
|
limit_req zone=ratelimit burst=10 nodelay; |
||||
|
|
||||
|
# 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; |
||||
|
proxy_set_header Host $host; |
||||
|
proxy_set_header X-Real-IP $remote_addr; |
||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
|
|
||||
|
proxy_pass http://app-service.budibase.svc.cluster.local:4002; |
||||
|
} |
||||
|
|
||||
|
location /db/ { |
||||
|
proxy_pass http://budibase-prod-svc-couchdb:5984; |
||||
|
rewrite ^/db/(.*)$ /$1 break; |
||||
|
} |
||||
|
|
||||
|
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; |
||||
|
proxy_set_header Host $http_host; |
||||
|
proxy_set_header Connection ""; |
||||
|
proxy_http_version 1.1; |
||||
|
chunked_transfer_encoding off; |
||||
|
|
||||
|
proxy_connect_timeout 300; |
||||
|
proxy_pass http://minio-service.budibase.svc.cluster.local:9000; |
||||
|
} |
||||
|
|
||||
|
client_header_timeout 60; |
||||
|
client_body_timeout 60; |
||||
|
keepalive_timeout 60; |
||||
|
|
||||
|
# 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; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,91 @@ |
|||||
|
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 { |
||||
|
include /etc/nginx/mime.types; |
||||
|
default_type application/octet-stream; |
||||
|
|
||||
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
||||
|
'$status $body_bytes_sent "$http_referer" ' |
||||
|
'"$http_user_agent" "$http_x_forwarded_for"'; |
||||
|
|
||||
|
map $http_upgrade $connection_upgrade { |
||||
|
default "upgrade"; |
||||
|
} |
||||
|
|
||||
|
server { |
||||
|
listen 10000 default_server; |
||||
|
server_name _; |
||||
|
client_max_body_size 1000m; |
||||
|
ignore_invalid_headers off; |
||||
|
proxy_buffering off; |
||||
|
|
||||
|
location /db/ { |
||||
|
proxy_pass http://couchdb-service:5984; |
||||
|
rewrite ^/db/(.*)$ /$1 break; |
||||
|
} |
||||
|
|
||||
|
location ~ ^/api/(system|admin|global)/ { |
||||
|
proxy_pass http://{{ address }}:4002; |
||||
|
} |
||||
|
|
||||
|
location /api/ { |
||||
|
proxy_read_timeout 120s; |
||||
|
proxy_connect_timeout 120s; |
||||
|
proxy_send_timeout 120s; |
||||
|
proxy_pass http://{{ address }}:4001; |
||||
|
} |
||||
|
|
||||
|
location /app_ { |
||||
|
proxy_pass http://{{ address }}:4001; |
||||
|
} |
||||
|
|
||||
|
location /app/ { |
||||
|
proxy_pass http://{{ address }}:4001; |
||||
|
rewrite ^/app/(.*)$ /$1 break; |
||||
|
} |
||||
|
|
||||
|
location /builder { |
||||
|
proxy_pass http://{{ address }}:3000; |
||||
|
rewrite ^/builder(.*)$ /builder/$1 break; |
||||
|
} |
||||
|
|
||||
|
location /builder/ { |
||||
|
proxy_pass http://{{ address }}:3000; |
||||
|
|
||||
|
proxy_http_version 1.1; |
||||
|
proxy_set_header Connection $connection_upgrade; |
||||
|
proxy_set_header Upgrade $http_upgrade; |
||||
|
proxy_set_header Host $host; |
||||
|
proxy_set_header X-Real-IP $remote_addr; |
||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
|
} |
||||
|
|
||||
|
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; |
||||
|
proxy_set_header Host $http_host; |
||||
|
|
||||
|
proxy_connect_timeout 300; |
||||
|
proxy_http_version 1.1; |
||||
|
proxy_set_header Connection ""; |
||||
|
chunked_transfer_encoding off; |
||||
|
|
||||
|
proxy_pass http://minio-service:9000; |
||||
|
} |
||||
|
|
||||
|
client_header_timeout 60; |
||||
|
client_body_timeout 60; |
||||
|
keepalive_timeout 60; |
||||
|
gzip off; |
||||
|
gzip_comp_level 4; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,2 @@ |
|||||
|
FROM nginx:latest |
||||
|
COPY nginx.conf /etc/nginx/nginx.conf |
||||
@ -0,0 +1,145 @@ |
|||||
|
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 { |
||||
|
limit_req_zone $binary_remote_addr zone=ratelimit:10m rate=10r/s; |
||||
|
include /etc/nginx/mime.types; |
||||
|
default_type application/octet-stream; |
||||
|
charset utf-8; |
||||
|
sendfile on; |
||||
|
tcp_nopush on; |
||||
|
tcp_nodelay on; |
||||
|
server_tokens off; |
||||
|
types_hash_max_size 2048; |
||||
|
|
||||
|
# buffering |
||||
|
client_body_buffer_size 1K; |
||||
|
client_header_buffer_size 1k; |
||||
|
client_max_body_size 1k; |
||||
|
ignore_invalid_headers off; |
||||
|
|
||||
|
|
||||
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
||||
|
'$status $body_bytes_sent "$http_referer" ' |
||||
|
'"$http_user_agent" "$http_x_forwarded_for"'; |
||||
|
|
||||
|
map $http_upgrade $connection_upgrade { |
||||
|
default "upgrade"; |
||||
|
} |
||||
|
|
||||
|
server { |
||||
|
listen 10000 default_server; |
||||
|
listen [::]:10000 default_server; |
||||
|
server_name _; |
||||
|
client_max_body_size 1000m; |
||||
|
ignore_invalid_headers off; |
||||
|
proxy_buffering off; |
||||
|
port_in_redirect off; |
||||
|
|
||||
|
# 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; |
||||
|
add_header Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdn.budi.live https://js.intercomcdn.com https://widget.intercom.io; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://fonts.googleapis.com https://rsms.me; object-src 'none'; base-uri 'self'; connect-src 'self' https://api-iam.intercom.io https://app.posthog.com wss://nexus-websocket-a.intercom.io; font-src 'self' data: https://cdn.jsdelivr.net https://fonts.gstatic.com https://rsms.me; frame-src 'self'; img-src http: https: data:; manifest-src 'self'; media-src 'self'; worker-src 'none';" always; |
||||
|
|
||||
|
location /app { |
||||
|
proxy_pass http://app-service:4002; |
||||
|
rewrite ^/app/(.*)$ /$1 break; |
||||
|
} |
||||
|
|
||||
|
location = / { |
||||
|
port_in_redirect off; |
||||
|
proxy_pass http://app-service:4002; |
||||
|
} |
||||
|
|
||||
|
location = /v1/update { |
||||
|
proxy_pass http://watchtower-service:8080; |
||||
|
} |
||||
|
|
||||
|
location /builder/ { |
||||
|
port_in_redirect off; |
||||
|
proxy_http_version 1.1; |
||||
|
proxy_set_header Connection $connection_upgrade; |
||||
|
proxy_set_header Upgrade $http_upgrade; |
||||
|
proxy_set_header Host $host; |
||||
|
proxy_set_header X-Real-IP $remote_addr; |
||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
|
proxy_pass http://app-service:4002; |
||||
|
} |
||||
|
|
||||
|
location ~ ^/(builder|app_) { |
||||
|
port_in_redirect off; |
||||
|
proxy_http_version 1.1; |
||||
|
proxy_set_header Connection $connection_upgrade; |
||||
|
proxy_set_header Upgrade $http_upgrade; |
||||
|
proxy_set_header Host $host; |
||||
|
proxy_set_header X-Real-IP $remote_addr; |
||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
|
proxy_pass http://app-service:4002; |
||||
|
} |
||||
|
|
||||
|
location ~ ^/api/(system|admin|global)/ { |
||||
|
proxy_pass http://worker-service:4003; |
||||
|
} |
||||
|
|
||||
|
location /worker/ { |
||||
|
proxy_pass http://worker-service:4003; |
||||
|
rewrite ^/worker/(.*)$ /$1 break; |
||||
|
} |
||||
|
|
||||
|
location /api/ { |
||||
|
# calls to the API are rate limited with bursting |
||||
|
limit_req zone=ratelimit burst=10 nodelay; |
||||
|
|
||||
|
# 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; |
||||
|
proxy_set_header Host $host; |
||||
|
proxy_set_header X-Real-IP $remote_addr; |
||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
||||
|
|
||||
|
proxy_pass http://app-service:4002; |
||||
|
} |
||||
|
|
||||
|
location /db/ { |
||||
|
proxy_pass http://couchdb-service:5984; |
||||
|
rewrite ^/db/(.*)$ /$1 break; |
||||
|
} |
||||
|
|
||||
|
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; |
||||
|
proxy_set_header Host $http_host; |
||||
|
|
||||
|
proxy_connect_timeout 300; |
||||
|
proxy_http_version 1.1; |
||||
|
proxy_set_header Connection ""; |
||||
|
chunked_transfer_encoding off; |
||||
|
proxy_pass http://minio-service:9000; |
||||
|
} |
||||
|
|
||||
|
client_header_timeout 60; |
||||
|
client_body_timeout 60; |
||||
|
keepalive_timeout 60; |
||||
|
|
||||
|
# 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; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,48 @@ |
|||||
|
import { |
||||
|
createAPIClient, |
||||
|
CookieUtils, |
||||
|
Constants, |
||||
|
} from "@budibase/frontend-core" |
||||
|
import { store } from "./builderStore" |
||||
|
import { get } from "svelte/store" |
||||
|
import { auth } from "./stores/portal" |
||||
|
|
||||
|
export const API = createAPIClient({ |
||||
|
attachHeaders: headers => { |
||||
|
// Attach app ID header from store
|
||||
|
headers["x-budibase-app-id"] = get(store).appId |
||||
|
|
||||
|
// Add csrf token if authenticated
|
||||
|
const user = get(auth).user |
||||
|
if (user?.csrfToken) { |
||||
|
headers["x-csrf-token"] = user.csrfToken |
||||
|
} |
||||
|
}, |
||||
|
|
||||
|
onError: error => { |
||||
|
const { url, message, status, method, handled } = error || {} |
||||
|
|
||||
|
// Log all API errors to Sentry
|
||||
|
// analytics.captureException(error)
|
||||
|
|
||||
|
// Log any errors that we haven't manually handled
|
||||
|
if (!handled) { |
||||
|
console.error("Unhandled error from API client", error) |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
// Log all errors to console
|
||||
|
console.warn(`[Builder] HTTP ${status} on ${method}:${url}\n\t${message}`) |
||||
|
|
||||
|
// Logout on 403's
|
||||
|
if (status === 403) { |
||||
|
// Remove cookies
|
||||
|
CookieUtils.removeCookie(Constants.Cookies.Auth) |
||||
|
|
||||
|
// Reload after removing cookie, go to login
|
||||
|
if (!url.includes("self") && !url.includes("login")) { |
||||
|
location.reload() |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
}) |
||||
@ -1,49 +0,0 @@ |
|||||
import { store } from "./index" |
|
||||
import { get as svelteGet } from "svelte/store" |
|
||||
import { removeCookie, Cookies } from "./cookies" |
|
||||
import { auth } from "stores/portal" |
|
||||
|
|
||||
const apiCall = |
|
||||
method => |
|
||||
async (url, body, headers = { "Content-Type": "application/json" }) => { |
|
||||
headers["x-budibase-app-id"] = svelteGet(store).appId |
|
||||
headers["x-budibase-api-version"] = "1" |
|
||||
|
|
||||
// add csrf token if authenticated
|
|
||||
const user = svelteGet(auth).user |
|
||||
if (user && user.csrfToken) { |
|
||||
headers["x-csrf-token"] = user.csrfToken |
|
||||
} |
|
||||
|
|
||||
const json = headers["Content-Type"] === "application/json" |
|
||||
const resp = await fetch(url, { |
|
||||
method: method, |
|
||||
body: json ? JSON.stringify(body) : body, |
|
||||
headers, |
|
||||
}) |
|
||||
if (resp.status === 403) { |
|
||||
if (url.includes("/api/templates")) { |
|
||||
return { json: () => [] } |
|
||||
} |
|
||||
removeCookie(Cookies.Auth) |
|
||||
// reload after removing cookie, go to login
|
|
||||
if (!url.includes("self") && !url.includes("login")) { |
|
||||
location.reload() |
|
||||
} |
|
||||
} |
|
||||
return resp |
|
||||
} |
|
||||
|
|
||||
export const post = apiCall("POST") |
|
||||
export const get = apiCall("GET") |
|
||||
export const patch = apiCall("PATCH") |
|
||||
export const del = apiCall("DELETE") |
|
||||
export const put = apiCall("PUT") |
|
||||
|
|
||||
export default { |
|
||||
post: apiCall("POST"), |
|
||||
get: apiCall("GET"), |
|
||||
patch: apiCall("PATCH"), |
|
||||
delete: apiCall("DELETE"), |
|
||||
put: apiCall("PUT"), |
|
||||
} |
|
||||
@ -1,16 +0,0 @@ |
|||||
import { get } from "builderStore/api" |
|
||||
|
|
||||
/** |
|
||||
* Fetches the definitions for component library components. This includes |
|
||||
* their props and other metadata from components.json. |
|
||||
* @param {string} appId - ID of the currently running app |
|
||||
*/ |
|
||||
export const fetchComponentLibDefinitions = async appId => { |
|
||||
const LIB_DEFINITION_URL = `/api/${appId}/components/definitions` |
|
||||
try { |
|
||||
const libDefinitionResponse = await get(LIB_DEFINITION_URL) |
|
||||
return await libDefinitionResponse.json() |
|
||||
} catch (err) { |
|
||||
console.error(`Error fetching component definitions for ${appId}`, err) |
|
||||
} |
|
||||
} |
|
||||
@ -1,23 +0,0 @@ |
|||||
import { writable } from "svelte/store" |
|
||||
import { generate } from "shortid" |
|
||||
|
|
||||
export const notificationStore = writable({ |
|
||||
notifications: [], |
|
||||
}) |
|
||||
|
|
||||
export function send(message, type = "default") { |
|
||||
notificationStore.update(state => { |
|
||||
state.notifications = [ |
|
||||
...state.notifications, |
|
||||
{ id: generate(), type, message }, |
|
||||
] |
|
||||
return state |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
export const notifier = { |
|
||||
danger: msg => send(msg, "danger"), |
|
||||
warning: msg => send(msg, "warning"), |
|
||||
info: msg => send(msg, "info"), |
|
||||
success: msg => send(msg, "success"), |
|
||||
} |
|
||||
@ -1,9 +0,0 @@ |
|||||
export function uuid() { |
|
||||
// always want to make this start with a letter, as this makes it
|
|
||||
// easier to use with template string bindings in the client
|
|
||||
return "cxxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g, c => { |
|
||||
const r = (Math.random() * 16) | 0, |
|
||||
v = c == "x" ? r : (r & 0x3) | 0x8 |
|
||||
return v.toString(16) |
|
||||
}) |
|
||||
} |
|
||||
@ -1,34 +0,0 @@ |
|||||
import api from "builderStore/api" |
|
||||
|
|
||||
export async function createUser(user) { |
|
||||
const CREATE_USER_URL = `/api/users/metadata` |
|
||||
const response = await api.post(CREATE_USER_URL, user) |
|
||||
return await response.json() |
|
||||
} |
|
||||
|
|
||||
export async function saveRow(row, tableId) { |
|
||||
const SAVE_ROW_URL = `/api/${tableId}/rows` |
|
||||
const response = await api.post(SAVE_ROW_URL, row) |
|
||||
|
|
||||
return await response.json() |
|
||||
} |
|
||||
|
|
||||
export async function deleteRow(row) { |
|
||||
const DELETE_ROWS_URL = `/api/${row.tableId}/rows` |
|
||||
return api.delete(DELETE_ROWS_URL, { |
|
||||
_id: row._id, |
|
||||
_rev: row._rev, |
|
||||
}) |
|
||||
} |
|
||||
|
|
||||
export async function fetchDataForTable(tableId) { |
|
||||
const FETCH_ROWS_URL = `/api/${tableId}/rows` |
|
||||
|
|
||||
const response = await api.get(FETCH_ROWS_URL) |
|
||||
const json = await response.json() |
|
||||
|
|
||||
if (response.status !== 200) { |
|
||||
throw new Error(json.message) |
|
||||
} |
|
||||
return json |
|
||||
} |
|
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue