2021-11-23 05:52:09 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
set -o nounset
|
|
|
|
|
|
|
|
|
|
CUSTOM_DOMAIN="$1"
|
|
|
|
|
|
|
|
|
|
# By default, container will use the auto-generate certificate by Let's Encrypt
|
|
|
|
|
SSL_CERT_PATH="/etc/letsencrypt/live/$CUSTOM_DOMAIN/fullchain.pem"
|
|
|
|
|
SSL_KEY_PATH="/etc/letsencrypt/live/$CUSTOM_DOMAIN/privkey.pem"
|
|
|
|
|
|
2021-11-23 08:17:44 +00:00
|
|
|
# In case of existing custom certificate, container will use them to configure SSL
|
2021-11-23 05:52:09 +00:00
|
|
|
if [[ -e "/appsmith-stacks/ssl/fullchain.pem" ]] && [[ -e "/appsmith-stacks/ssl/privkey.pem" ]]; then
|
2022-09-26 04:11:38 +00:00
|
|
|
SSL_CERT_PATH="/appsmith-stacks/ssl/fullchain.pem"
|
|
|
|
|
SSL_KEY_PATH="/appsmith-stacks/ssl/privkey.pem"
|
2021-11-23 05:52:09 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cat <<EOF
|
2021-11-23 10:20:37 +00:00
|
|
|
map \$http_x_forwarded_proto \$origin_scheme {
|
|
|
|
|
default \$http_x_forwarded_proto;
|
|
|
|
|
'' \$scheme;
|
2021-11-23 08:17:44 +00:00
|
|
|
}
|
2022-10-14 01:00:27 +00:00
|
|
|
|
|
|
|
|
map \$http_x_forwarded_host \$origin_host {
|
|
|
|
|
default \$http_x_forwarded_host;
|
|
|
|
|
'' \$host;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-24 08:17:25 +00:00
|
|
|
# redirect log to stdout for supervisor to capture
|
|
|
|
|
access_log /dev/stdout;
|
2021-11-23 08:17:44 +00:00
|
|
|
|
2021-11-23 05:52:09 +00:00
|
|
|
server {
|
|
|
|
|
listen 80;
|
|
|
|
|
server_name $CUSTOM_DOMAIN;
|
|
|
|
|
|
|
|
|
|
return 301 https://\$host\$request_uri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
server {
|
|
|
|
|
listen 443 ssl http2;
|
|
|
|
|
server_name _;
|
|
|
|
|
|
|
|
|
|
ssl_certificate $SSL_CERT_PATH;
|
|
|
|
|
ssl_certificate_key $SSL_KEY_PATH;
|
|
|
|
|
|
|
|
|
|
include /appsmith-stacks/data/certificate/conf/options-ssl-nginx.conf;
|
|
|
|
|
ssl_dhparam /appsmith-stacks/data/certificate/conf/ssl-dhparams.pem;
|
|
|
|
|
|
2022-07-21 07:33:35 +00:00
|
|
|
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors
|
2022-08-02 10:11:52 +00:00
|
|
|
add_header Content-Security-Policy "frame-ancestors ${APPSMITH_ALLOWED_FRAME_ANCESTORS-'self' *}";
|
2022-07-21 07:33:35 +00:00
|
|
|
|
2022-03-24 07:47:36 +00:00
|
|
|
location = /supervisor {
|
|
|
|
|
return 301 /supervisor/;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /supervisor/ {
|
2022-10-14 01:00:27 +00:00
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_buffering off;
|
|
|
|
|
proxy_max_temp_file_size 0;
|
|
|
|
|
proxy_redirect off;
|
|
|
|
|
proxy_set_header Host \$http_host/supervisor/;
|
|
|
|
|
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 \$origin_scheme;
|
|
|
|
|
proxy_set_header X-Forwarded-Host \$origin_host;
|
|
|
|
|
proxy_set_header Connection "";
|
|
|
|
|
proxy_pass http://localhost:9001/;
|
|
|
|
|
auth_basic "Protected";
|
|
|
|
|
auth_basic_user_file /etc/nginx/passwords;
|
2022-03-24 07:47:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proxy_set_header X-Forwarded-Proto \$origin_scheme;
|
2022-10-14 01:00:27 +00:00
|
|
|
proxy_set_header X-Forwarded-Host \$origin_host;
|
2022-03-24 07:47:36 +00:00
|
|
|
|
2023-02-20 15:04:02 +00:00
|
|
|
client_max_body_size 150m;
|
2021-11-23 05:52:09 +00:00
|
|
|
|
|
|
|
|
gzip on;
|
2022-08-05 11:10:38 +00:00
|
|
|
gzip_types *;
|
|
|
|
|
|
|
|
|
|
server_tokens off;
|
2021-11-23 05:52:09 +00:00
|
|
|
|
|
|
|
|
root /opt/appsmith/editor;
|
2022-09-26 04:11:38 +00:00
|
|
|
index index.html;
|
|
|
|
|
error_page 404 /;
|
2021-11-23 05:52:09 +00:00
|
|
|
|
2022-01-01 06:09:49 +00:00
|
|
|
location /.well-known/acme-challenge/ {
|
|
|
|
|
root /appsmith-stacks/data/certificate/certbot;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 05:52:09 +00:00
|
|
|
location / {
|
2023-04-19 12:50:59 +00:00
|
|
|
try_files /loading.html \$uri /index.html =404;
|
2021-11-23 05:52:09 +00:00
|
|
|
}
|
|
|
|
|
|
2023-04-19 01:12:01 +00:00
|
|
|
location ~ ^/static/(js|css|media)\b {
|
|
|
|
|
# Files in these folders are hashed, so we can set a long cache time.
|
|
|
|
|
add_header Cache-Control "max-age=31104000, immutable"; # 360 days
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-26 04:11:38 +00:00
|
|
|
# If the path has an extension at the end, then respond with 404 status if the file not found.
|
2022-10-14 07:53:09 +00:00
|
|
|
location ~ ^/(?!supervisor/).*\.[a-z]+$ {
|
2022-09-26 04:11:38 +00:00
|
|
|
try_files \$uri =404;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-23 05:52:09 +00:00
|
|
|
location /api {
|
|
|
|
|
proxy_pass http://localhost:8080;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /oauth2 {
|
|
|
|
|
proxy_pass http://localhost:8080;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /login {
|
|
|
|
|
proxy_pass http://localhost:8080;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
location /rts {
|
2023-02-15 01:36:02 +00:00
|
|
|
proxy_pass http://localhost:${APPSMITH_RTS_PORT:-8091};
|
2021-11-23 05:52:09 +00:00
|
|
|
proxy_http_version 1.1;
|
|
|
|
|
proxy_set_header Host \$host;
|
|
|
|
|
proxy_set_header Connection 'upgrade';
|
|
|
|
|
proxy_set_header Upgrade \$http_upgrade;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
EOF
|