mirror of
https://github.com/AppFlowy-IO/AppFlowy-Cloud.git
synced 2025-04-22 21:07:07 -04:00
215 lines
7.3 KiB
Nginx Configuration File
215 lines
7.3 KiB
Nginx Configuration File
# Minimal nginx configuration for AppFlowy-Cloud
|
|
# Self Hosted AppFlowy Cloud user should alter this file to suit their needs
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
# docker dns resolver
|
|
resolver 127.0.0.11 valid=10s;
|
|
|
|
map $http_upgrade $connection_upgrade {
|
|
default upgrade;
|
|
'' close;
|
|
}
|
|
|
|
server {
|
|
listen 8080;
|
|
|
|
# https://github.com/nginxinc/nginx-prometheus-exporter
|
|
location = /stub_status {
|
|
stub_status;
|
|
}
|
|
}
|
|
|
|
|
|
server {
|
|
ssl_certificate /etc/nginx/ssl/certificate.crt;
|
|
ssl_certificate_key /etc/nginx/ssl/private_key.key;
|
|
|
|
listen 80;
|
|
listen 443 ssl;
|
|
client_max_body_size 10M;
|
|
|
|
underscores_in_headers on;
|
|
|
|
# GoTrue
|
|
location /gotrue/ {
|
|
set $gotrue gotrue;
|
|
proxy_pass http://$gotrue:9999;
|
|
|
|
rewrite ^/gotrue(/.*)$ $1 break;
|
|
|
|
# Allow headers like redirect_to to be handed over to the gotrue
|
|
# for correct redirecting
|
|
proxy_set_header Host $http_host;
|
|
proxy_pass_request_headers on;
|
|
}
|
|
|
|
# WebSocket
|
|
location /ws {
|
|
set $appflowy_cloud appflowy_cloud;
|
|
proxy_pass http://$appflowy_cloud:8000;
|
|
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
proxy_set_header Host $host;
|
|
proxy_read_timeout 86400;
|
|
}
|
|
|
|
# AppFlowy-Cloud
|
|
# created a separate location block for handling CORS preflight (OPTIONS) requests specifically for the /api endpoint.
|
|
location = /api/options {
|
|
if ($http_origin ~* (http://127.0.0.1:8000)) {
|
|
add_header 'Access-Control-Allow-Origin' $http_origin;
|
|
}
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, PATCH';
|
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, Accept, Client-Version';
|
|
add_header 'Access-Control-Max-Age' 3600;
|
|
add_header 'Content-Type' 'text/plain; charset=utf-8';
|
|
add_header 'Content-Length' 0;
|
|
return 204;
|
|
}
|
|
|
|
location /api/chat {
|
|
set $appflowy_cloud appflowy_cloud;
|
|
proxy_pass http://$appflowy_cloud:8000;
|
|
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Connection "";
|
|
chunked_transfer_encoding on;
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
|
|
proxy_read_timeout 600s;
|
|
proxy_connect_timeout 600s;
|
|
proxy_send_timeout 600s;
|
|
}
|
|
|
|
location /api/import {
|
|
set $appflowy_cloud appflowy_cloud;
|
|
proxy_pass http://$appflowy_cloud:8000;
|
|
|
|
# Set headers
|
|
proxy_set_header X-Request-Id $request_id;
|
|
proxy_set_header Host $http_host;
|
|
|
|
# Handle CORS
|
|
if ($http_origin ~* (http://127.0.0.1:8000)) {
|
|
add_header 'Access-Control-Allow-Origin' $http_origin always;
|
|
}
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH, OPTIONS' always;
|
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, Accept' always;
|
|
add_header 'Access-Control-Max-Age' 3600 always;
|
|
|
|
# Timeouts
|
|
proxy_read_timeout 600s;
|
|
proxy_connect_timeout 600s;
|
|
proxy_send_timeout 600s;
|
|
|
|
# Disable buffering for large file uploads
|
|
proxy_request_buffering off;
|
|
proxy_buffering off;
|
|
proxy_cache off;
|
|
client_max_body_size 2G;
|
|
}
|
|
|
|
location /api {
|
|
set $appflowy_cloud appflowy_cloud;
|
|
proxy_pass http://$appflowy_cloud:8000;
|
|
|
|
proxy_set_header X-Request-Id $request_id;
|
|
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 $scheme;
|
|
|
|
# Set CORS headers for other requests
|
|
if ($http_origin ~* (http://127.0.0.1:8000)) {
|
|
add_header 'Access-Control-Allow-Origin' $http_origin always;
|
|
}
|
|
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, PATCH' always;
|
|
add_header 'Access-Control-Allow-Headers' 'Content-Type, Authorization, Accept, Client-Version' always;
|
|
add_header 'Access-Control-Max-Age' 3600 always;
|
|
|
|
location ~* ^/api/workspace/([a-zA-Z0-9_-]+)/publish$ {
|
|
set $appflowy_cloud appflowy_cloud;
|
|
proxy_pass http://$appflowy_cloud:8000;
|
|
proxy_request_buffering off;
|
|
client_max_body_size 256M;
|
|
}
|
|
}
|
|
|
|
# AppFlowy AI
|
|
location /ai {
|
|
set $ai ai;
|
|
proxy_pass http://$ai:5001;
|
|
proxy_set_header Host $host;
|
|
proxy_pass_request_headers on;
|
|
}
|
|
|
|
# Minio Web UI
|
|
# Derive from: https://min.io/docs/minio/linux/integrations/setup-nginx-proxy-with-minio.html
|
|
# Optional Module, comment this section if you are did not deploy minio in docker-compose.yml
|
|
location /minio/ {
|
|
set $minio minio;
|
|
proxy_pass http://$minio:9001;
|
|
|
|
rewrite ^/minio/(.*) /$1 break;
|
|
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 $scheme;
|
|
proxy_set_header X-NginX-Proxy true;
|
|
|
|
## This is necessary to pass the correct IP to be hashed
|
|
real_ip_header X-Real-IP;
|
|
|
|
proxy_connect_timeout 300;
|
|
|
|
## To support websockets in MinIO versions released after January 2023
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
# Some environments may encounter CORS errors (Kubernetes + Nginx Ingress)
|
|
# Uncomment the following line to set the Origin request to an empty string
|
|
# proxy_set_header Origin '';
|
|
|
|
chunked_transfer_encoding off;
|
|
}
|
|
|
|
# PgAdmin
|
|
# Optional Module, comment this section if you are did not deploy pgadmin in docker-compose.yml
|
|
location /pgadmin/ {
|
|
set $pgadmin pgadmin;
|
|
proxy_pass http://$pgadmin:80;
|
|
|
|
proxy_set_header X-Script-Name /pgadmin;
|
|
proxy_set_header X-Scheme $scheme;
|
|
proxy_set_header Host $host;
|
|
proxy_redirect off;
|
|
}
|
|
|
|
# Portainer
|
|
# Optional Module, comment this section if you are did not deploy portainer in docker-compose.yml
|
|
location /portainer/ {
|
|
set $portainer portainer;
|
|
proxy_pass http://$portainer:9000;
|
|
|
|
rewrite ^/portainer/(.*) /$1 break;
|
|
}
|
|
|
|
# Admin Frontend
|
|
# Optional Module, comment this section if you are did not deploy admin_frontend in docker-compose.yml
|
|
location / {
|
|
set $admin_frontend admin_frontend;
|
|
proxy_pass http://$admin_frontend:3000;
|
|
|
|
proxy_set_header X-Scheme $scheme;
|
|
proxy_set_header Host $host;
|
|
}
|
|
}
|
|
|
|
}
|