For paths with an extension, give 404 if missing (#17035)

This commit is contained in:
Shrikant Sharat Kandula 2022-09-26 09:41:38 +05:30 committed by GitHub
parent 4456687400
commit 24655f6ceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

View File

@ -5,7 +5,7 @@ set -o nounset
CUSTOM_DOMAIN="$1"
if [[ -z $CUSTOM_DOMAIN ]]; then
CUSTOM_DOMAIN=_
CUSTOM_DOMAIN=_
fi
cat <<EOF
@ -28,7 +28,8 @@ server {
server_tokens off;
root /opt/appsmith/editor;
index index.html index.htm;
index index.html;
error_page 404 /;
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors
add_header Content-Security-Policy "frame-ancestors ${APPSMITH_ALLOWED_FRAME_ANCESTORS-'self' *}";
@ -66,6 +67,11 @@ server {
try_files \$uri /index.html =404;
}
# If the path has an extension at the end, then respond with 404 status if the file not found.
location ~ \.[a-z]+$ {
try_files \$uri =404;
}
location /api {
proxy_pass http://localhost:8080;
}

View File

@ -10,8 +10,8 @@ SSL_KEY_PATH="/etc/letsencrypt/live/$CUSTOM_DOMAIN/privkey.pem"
# In case of existing custom certificate, container will use them to configure SSL
if [[ -e "/appsmith-stacks/ssl/fullchain.pem" ]] && [[ -e "/appsmith-stacks/ssl/privkey.pem" ]]; then
SSL_CERT_PATH="/appsmith-stacks/ssl/fullchain.pem"
SSL_KEY_PATH="/appsmith-stacks/ssl/privkey.pem"
SSL_CERT_PATH="/appsmith-stacks/ssl/fullchain.pem"
SSL_KEY_PATH="/appsmith-stacks/ssl/privkey.pem"
fi
cat <<EOF
@ -73,7 +73,8 @@ server {
server_tokens off;
root /opt/appsmith/editor;
index index.html index.htm;
index index.html;
error_page 404 /;
location /.well-known/acme-challenge/ {
root /appsmith-stacks/data/certificate/certbot;
@ -83,6 +84,11 @@ server {
try_files \$uri /index.html =404;
}
# If the path has an extension at the end, then respond with 404 status if the file not found.
location ~ \.[a-z]+$ {
try_files \$uri =404;
}
location /api {
proxy_pass http://localhost:8080;
}