Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): disallow robots #26

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added nginx-core/default-data/favicon.ico
Binary file not shown.
2 changes: 2 additions & 0 deletions nginx-core/default-data/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /
3 changes: 3 additions & 0 deletions nginx-core/etc/nginx/entrypoint.d/30-copy-default-data.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/sh
set -eu

ME=$(basename "$0")

if [ -d "/default-data" ]; then
# copy without overwriting existing files
echo "$ME: Copy default data from /default-data to $NGINX_DOCUMENT_ROOT"
cp -anv /default-data/* $NGINX_DOCUMENT_ROOT/
fi

Expand Down
13 changes: 13 additions & 0 deletions nginx-core/etc/nginx/entrypoint.d/40-disallow-robots.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

set -eu

ME=$(basename "$0")

# replace the default robots.txt with a disallow all
if [ ${NGINX_DISALLOW_ROBOTS:-} == 1 ]; then
echo "$ME: Replace robots.txt to disallow all robots"
cp -afv /default-data/robots.txt $NGINX_DOCUMENT_ROOT/
fi

exit 0
13 changes: 6 additions & 7 deletions nginx-core/etc/nginx/entrypoint.d/90-cleanup-conf.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/sh
set -eu

# Remove some configs base on envs
cleanup_confings() {
if [ -z ${NGINX_FORCE_DOMAIN:-} ]; then
rm -fv /etc/nginx/conf.d/location.d/40-force-domain.conf
fi
}
ME=$(basename "$0")

cleanup_confings
# Remove some configs base on envs
if [ -z ${NGINX_FORCE_DOMAIN:-} ]; then
echo "$ME: Remove force domain location config"
rm -fv /etc/nginx/conf.d/location.d/40-force-domain.conf
fi

exit 0
Loading