Skip to content

Commit

Permalink
chore: add variables to configure cors headers
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Zipitria <[email protected]>
  • Loading branch information
fzipi committed Dec 1, 2024
1 parent 8a97d6b commit c7fe283
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ LABEL maintainer="Felipe Zipitria <[email protected]>"
ENV \
ACCESSLOG=/var/log/nginx/access.log \
BACKEND=http://localhost:80 \
CORS_HEADER_403_ALLOW_ORIGIN="*" \
CORS_HEADER_403_ALLOW_METHODS="GET, POST, PUT, DELETE, OPTIONS" \
CORS_HEADER_403_CONTENT_TYPE="text/plain" \
CORS_HEADER_403_MAX_AGE=3600 \
CORS_HEADER_ACCESS_CONTROL_ALLOW_HEADERS="*" \
DNS_SERVER= \
ERRORLOG=/var/log/nginx/error.log \
KEEPALIVE_TIMEOUT=60s \
Expand Down
5 changes: 5 additions & 0 deletions nginx/Dockerfile-alpine
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ LABEL maintainer="Felipe Zipitria <[email protected]>"
ENV \
ACCESSLOG=/var/log/nginx/access.log \
BACKEND=http://localhost:80 \
CORS_HEADER_403_ALLOW_ORIGIN="*" \
CORS_HEADER_403_ALLOW_METHODS="GET, POST, PUT, DELETE, OPTIONS" \
CORS_HEADER_403_CONTENT_TYPE="text/plain" \
CORS_HEADER_403_MAX_AGE=3600 \
CORS_HEADER_ACCESS_CONTROL_ALLOW_HEADERS="*" \
DNS_SERVER= \
ERRORLOG=/var/log/nginx/error.log \
KEEPALIVE_TIMEOUT=60s \
Expand Down
5 changes: 5 additions & 0 deletions nginx/templates/includes/cors.conf.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
more_set_headers -s 403 'Content-Type' '${CORS_CONTENT_TYPE}';
more_set_headers -s 403 'Access-Control-Allow-Origin' '*';
more_set_headers -s 403 'Access-Control-Max-Age' '3600';
more_set_headers -s 403 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
more_set_headers 'Access-Control-Allow-Headers' '*';
1 change: 1 addition & 0 deletions nginx/templates/nginx.conf.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load_module modules/ngx_http_modsecurity_module.so;
# allows to add cors headers when replying with 403
load_module modules/ngx_http_headers_more_filter_module.so;

worker_processes auto;
Expand Down

0 comments on commit c7fe283

Please sign in to comment.