Skip to content

Commit

Permalink
fix(nginx-core): reorganize configuration files to fix many issues! (#81
Browse files Browse the repository at this point in the history
)
  • Loading branch information
alimd authored Nov 9, 2024
2 parents c55a1de + ca26449 commit 9adbbe6
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 28 deletions.
2 changes: 1 addition & 1 deletion nginx-core/etc/nginx/entrypoint.d/91-force-domain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ test -n "${NGINX_FORCE_DOMAIN:-}" && exit 0

ME=$(basename "$0")
echo "$ME: Remove force domain location config"
rm -fv /etc/nginx/conf.d/location.d/40-force-domain.conf
rm -fv /etc/nginx/conf.d/location.d/root.d/30-force-domain.conf

exit 0
2 changes: 1 addition & 1 deletion nginx-core/etc/nginx/entrypoint.d/92-auto-webp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ test -n "${NGINX_AUTO_WEBP:-}" && exit 0
ME=$(basename "$0")
echo "$ME: Remove auto webp config"
rm -fv /etc/nginx/conf.d/http.d/42-map-webp.conf
rm -fv /etc/nginx/conf.d/location.d/60-webp.conf
rm -fv /etc/nginx/conf.d/location.d/50-webp.conf

exit 0
2 changes: 1 addition & 1 deletion nginx-core/etc/nginx/entrypoint.d/93-cors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ test -n "${NGINX_CORS_ENABLE:-}" && exit 0

ME=$(basename "$0")
echo "$ME: Remove CORS config"
rm -fv /etc/nginx/conf.d/location.d/70-cors.conf
rm -fv /etc/nginx/conf.d/location.d/root.d/10-cors.conf

exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ location ~* (?:\.(?:bak|conf|dist|fla|in[ci]|log|psd|sh|sql|sw[op]|lock)|~)$ {
}

location ~* \.(pl|cgi|py|sh|lua)$ {
return 444;
deny all;
}

location ~* (w00tw00t) {
return 444;
deny all;
}

location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
return 444;
deny all;
}

location = /robots.txt {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if ($redirect_uri) {
return $NGINX_FORCE_REDIRECT_STATUS $redirect_uri;
}
break;
}
18 changes: 0 additions & 18 deletions nginx-core/etc/nginx/templates/location.d/70-cors.conf.template

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
location / {
include /etc/nginx/conf.d/location.d/root.d/*.conf;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
add_header 'Access-Control-Allow-Origin' $NGINX_CORS_ORIGIN;
add_header 'Access-Control-Allow-Methods' $NGINX_CORS_METHODS;
add_header 'Access-Control-Allow-Headers' $NGINX_CORS_HEADERS;
add_header 'Access-Control-Max-Age' $NGINX_CORS_MAXAGE;

# Handle OPTIONS requests (preflight requests for complex requests)
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' $NGINX_CORS_ORIGIN;
add_header 'Access-Control-Allow-Methods' $NGINX_CORS_METHODS;
add_header 'Access-Control-Allow-Headers' $NGINX_CORS_HEADERS;
add_header 'Access-Control-Max-Age' $NGINX_CORS_MAXAGE;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;

return 204;
break;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
limit_except HEAD GET OPTIONS {
deny all;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if ($host != $NGINX_FORCE_DOMAIN) {
return $NGINX_FORCE_DOMAIN_STATUS $scheme://$NGINX_FORCE_DOMAIN$request_uri;
break;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ location = / {
# return static json for home page
default_type application/json;
return 200 '{"ok": true, "data": "..:: Alwatr NGINX ::.."}';
break;
}

0 comments on commit 9adbbe6

Please sign in to comment.