Skip to content

Commit

Permalink
feat(nginx): allow blocking certain user-agents on staging
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKostka committed Oct 30, 2023
1 parent 5bf9dc6 commit 21529a8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions k8s/helmfile/env/local/platform-nginx.nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ map $request_uri $mwgroup {
default "web";
}

map $http_user_agent $blocked_agent {
~Bytespider 1;
default 0;
}

server {
listen 8080;
server_name _; # This is just an invalid value which will never trigger on a real hostname.
Expand Down Expand Up @@ -65,6 +70,10 @@ server {

proxy_max_temp_file_size 1024m;

if ($blocked_agent) {
return 444;
}

# Allowoverriding the group decision using the magic header
if ($http_x_wbstack_alpha) {
set $mwgroup "alpha";
Expand Down
9 changes: 9 additions & 0 deletions k8s/helmfile/env/staging/platform-nginx.nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ map $request_uri $mwgroup {
default "web";
}

map $http_user_agent $blocked_agent {
~Bytespider 1;
default 0;
}

server {
listen 8080;
server_name _; # This is just an invalid value which will never trigger on a real hostname.
Expand Down Expand Up @@ -65,6 +70,10 @@ server {

proxy_max_temp_file_size 1024m;

if ($blocked_agent) {
return 444;
}

# Allowoverriding the group decision using the magic header
if ($http_x_wbstack_alpha) {
set $mwgroup "alpha";
Expand Down

0 comments on commit 21529a8

Please sign in to comment.