openresty / openresty/headers-more-nginx-module

include -> if -> more_set_headers

Open
#98 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
1.8k
Forks
236
Avg merge
1h 34m
Merged PRs (30d)
2

Description

I found a problem: if I use the following construction, then the header is missing in the answer:

location {
  include /etc/nginx/default.d/cors.conf;
  ..
}

/etc/nginx/default.d/cors.conf:

more_set_headers 'Access-Control-Allow-Origin: *';
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE';
more_set_headers 'Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
more_set_headers 'Access-Control-Expose-Headers: Content-Length,Content-Range';

if ( $request_method = 'OPTIONS' ) {
  more_set_headers 'Access-Control-Max-Age: 1728000';
  more_set_headers 'Content-Type: text/plain; charset=utf-8';
  more_set_headers 'Content-Length: 0';
  return 204;
}

The answer is present only the first part to the block 'if'

When using schemes 'include -> more_set_headers' and 'if -> more_set_headers' all heders will be added correctly.

nginx version 1.17.0
headers-more-nginx-module 0.33

# nginx -V
nginx version: nginx/1.17.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
built with LibreSSL 2.9.2
TLS SNI support enabled
configure arguments: --prefix=/var/www/html --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules/ --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-stream --with-stream_ssl_module --with-pcre --with-openssl=./libressl-2.9.2 --add-module=ngx_devel_kit-0.3.1rc1 --add-module=lua-nginx-module-0.10.15 --add-module=njs-0.3.2/nginx --add-module=nginx-module-vts-0.1.18 --add-module=ngx_brotli --add-module=ngx_cache_purge-2.3 --add-module=ngx_http_geoip2_module-3.2 --add-module=echo-nginx-module-0.61 --add-module=nginx_upstream_check_module --add-module=nginx-auth-ldap-git20170725 --add-module=headers-more-nginx-module-0.33 --add-module=nginx-vod-module-1.24 --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DNGX_HAVE_MD5=0 -DNGX_LUA_USE_ASSERT -DNGX_LUA_ABORT_AT_PANIC -I/usr/include/luajit-2.0 -I/usr/include/httpd' --with-ld-opt='-Wl,-E -lrt'

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the configuration using nginx 1.17.0 and headers-more-nginx-module 0.33, comparing the include-to-more_set_headers and if-to-more_set_headers arrangements shown in the report. Trace why headers after the if block are absent; the work is done when the reported configuration produces all expected CORS headers, including the OPTIONS response headers.

Written by the indexing model from the issue text.

Assessment

Tech stack
nginx
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.